Help us shape the future of Go! Take the 2026 Go Developer Survey

git

package
v1.23.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSuchRemote = errors.New("no such remote")
View Source
var ErrNotRepository = errors.New("not a git repository")

Functions

This section is empty.

Types

type Cli

type Cli struct {
	// contains filtered or unexported fields
}

func NewCli

func NewCli(commandRunner exec.CommandRunner) *Cli

func (*Cli) AddFile

func (cli *Cli) AddFile(ctx context.Context, repositoryPath string, filespec string) error

func (*Cli) AddFileExecPermission

func (cli *Cli) AddFileExecPermission(ctx context.Context, repositoryPath string, file string) error

func (*Cli) AddRemote

func (cli *Cli) AddRemote(ctx context.Context, repositoryPath string, remoteName string, remoteUrl string) error

func (*Cli) CheckInstalled

func (cli *Cli) CheckInstalled(ctx context.Context) error

func (*Cli) Commit

func (cli *Cli) Commit(ctx context.Context, repositoryPath string, message string) error

func (*Cli) GetCurrentBranch

func (cli *Cli) GetCurrentBranch(ctx context.Context, repositoryPath string) (string, error)

func (*Cli) GetRemoteUrl

func (cli *Cli) GetRemoteUrl(ctx context.Context, repositoryPath string, remoteName string) (string, error)

func (*Cli) GetRepoRoot

func (cli *Cli) GetRepoRoot(ctx context.Context, repositoryPath string) (string, error)

func (*Cli) GetStatus

func (cli *Cli) GetStatus(ctx context.Context, repositoryPath string) (string, error)

GetStatus returns the porcelain status output of the repository. An empty string indicates a clean working directory with no uncommitted changes.

func (*Cli) InitRepo

func (cli *Cli) InitRepo(ctx context.Context, repositoryPath string) error

func (*Cli) InstallUrl

func (cli *Cli) InstallUrl() string

func (*Cli) IsDirty

func (cli *Cli) IsDirty(ctx context.Context, repositoryPath string) (bool, error)

IsDirty returns true if the repository has uncommitted changes including staged, unstaged, or untracked files.

func (*Cli) IsUntrackedFile

func (cli *Cli) IsUntrackedFile(ctx context.Context, repositoryPath string, filePath string) (bool, error)

func (*Cli) ListStagedFiles

func (cli *Cli) ListStagedFiles(ctx context.Context, repositoryPath string) (string, error)

func (*Cli) Name

func (cli *Cli) Name() string

func (*Cli) PushUpstream

func (cli *Cli) PushUpstream(ctx context.Context, repositoryPath string, origin string, branch string) error

func (*Cli) SetCredentialStore

func (cli *Cli) SetCredentialStore(ctx context.Context, repositoryPath string) error

func (*Cli) SetGitHubAuthForRepo

func (cli *Cli) SetGitHubAuthForRepo(ctx context.Context, repositoryPath, credential, ghPath string) error

SetGitHubAuthForRepo creates git config for the repositoryPath like

[credential "https://github.com"] (when credential is equal to "https://github.com") helper = helper = !ghPath auth git-credential

This way, git commands run from repositoryPath will use gh as auth credential. Note: Removes any previous configuration for the credential. Note: `helper = ` is intentional to break the chain of previously configured global helpers. See: https://github.com/cli/cli/issues/3796 for more about this strategy.

func (*Cli) ShallowClone

func (cli *Cli) ShallowClone(ctx context.Context, repositoryPath string, branch string, target string) error

func (*Cli) UpdateRemote

func (cli *Cli) UpdateRemote(ctx context.Context, repositoryPath string, remoteName string, remoteUrl string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL