Documentation
¶
Overview ¶
Package gitx runs the few git commands the loop needs.
Index ¶
- func Binary() string
- func DefaultBranch(dir string) string
- func NeedsPrompt(msg string) bool
- func PRRef(number int) string
- func ParseRemote(remote string) (host, repo string)
- func ReadHead(dir string) (oid, branch string, ok bool)
- func ReadUpstream(dir string) (branch string, ok bool)
- func RemoteURL(dir, remote string) string
- type Access
- type Cache
- type Error
- type Exec
- type Git
- func (g Git) Changed(ctx context.Context, dir string) (int, error)
- func (g Git) CheckedOutAt(ctx context.Context, dir, branch string) (string, error)
- func (g Git) DirtyTracked(ctx context.Context, dir string) (bool, error)
- func (g Git) FetchPR(ctx context.Context, dir string, number int, heads ...string) error
- func (g Git) FetchTracking(ctx context.Context, dir string) (remote, branch string, err error)
- func (g Git) HasCommit(ctx context.Context, dir, oid string) (bool, error)
- func (g Git) Head(ctx context.Context, dir string) (string, error)
- func (g Git) Ignored(ctx context.Context, dir string) ([]string, error)
- func (g Git) IsAncestor(ctx context.Context, dir, ancestor, commit string) (bool, error)
- func (g Git) LocalBranchTip(ctx context.Context, dir, branch string) (string, error)
- func (g Git) LsRemote(ctx context.Context, dir string) error
- func (g Git) RemoteHasBranch(ctx context.Context, dir, remote, branch string) (bool, error)
- func (g Git) ResetHard(ctx context.Context, dir, ref string) error
- func (g Git) TrackBranch(ctx context.Context, dir, branch string) (renamed bool, err error)
- func (g Git) TrackFetchedBranch(ctx context.Context, dir, branch string) (renamed bool, err error)
- func (g Git) Unpushed(ctx context.Context, dir string) (int, error)
- func (g Git) UpdateRef(ctx context.Context, dir, ref, newOid, oldOid string) error
- func (g Git) UpstreamBranch(ctx context.Context, dir string) (string, error)
- func (g Git) WorktreeAddDetached(ctx context.Context, dir, path, commit string) error
- func (g Git) WorktreeRemove(ctx context.Context, dir, path string) error
- type Metered
- type Observed
- type Runner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Binary ¶ added in v0.2.0
func Binary() string
Binary is the git to spawn: the one PATH names, except that the macOS xcrun shim is replaced by the git it would run.
func DefaultBranch ¶
DefaultBranch is the branch origin/HEAD of the checkout at dir names, read from the repository files so a sweep spawns no git process per repository. It is empty when origin/HEAD is not set and for a reftable repository, which keeps no ref files.
func NeedsPrompt ¶
NeedsPrompt reports whether a git or ssh error means the access needs a credential, a key or a host key the process could not get without asking.
func ParseRemote ¶
ParseRemote is the host and the repository path, without ".git", of a remote URL: scp-like (git@github.com:acme/widget.git), ssh:// or https://. Both are empty for a local path.
func ReadHead ¶
ReadHead reads the branch and the commit HEAD of the checkout at dir names from the repository files. branch is empty for a detached HEAD. ok is false when the files do not answer: a reftable repository, a symbolic ref or any unexpected content, so the caller asks git.
func ReadUpstream ¶
ReadUpstream reads the remote branch the current branch of the checkout at dir tracks from the repository files; branch is empty when it tracks none. ok is false whenever the files cannot answer with certainty, so the caller asks git: includes, worktree config, any syntax the parser does not fully understand (comments, continuations, quotes, unusual headers), a remote without exactly the standard fetch refspec, or a layout other than loose and packed refs. Only the repository's own config is read: branch settings in the user or system config are not seen.
Types ¶
type Access ¶
type Access struct {
Host string
At time.Time
// Op names the operation and its subject, such as "fetch of acme/widget#7".
Op string
Err string
}
Access is the outcome of one git operation that talked to a remote host.
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache remembers ancestry answers, which never change for a pair of commits git knows, across the sweeps of one process.
type Git ¶
Git runs git through R; C, when set, remembers ancestry answers.
func (Git) Changed ¶
Changed counts modified and untracked files, whatever status.showUntrackedFiles says.
func (Git) CheckedOutAt ¶
CheckedOutAt is the path of the worktree that has branch checked out, empty when none has.
func (Git) DirtyTracked ¶
DirtyTracked reports modified tracked files; untracked files do not block a reset.
func (Git) FetchPR ¶
FetchPR fetches the pull request's head into PRRef and, in the same fetch, each of heads, branches of origin, into its remote-tracking ref. A head origin lacks fails the whole fetch, so then it fetches the pull request alone.
func (Git) FetchTracking ¶
FetchTracking fetches the remote the current branch tracks, origin when it tracks none, and returns that remote and the tracked branch, "" for none. It does not prune: the pull request refs under refs/remotes are shared by every worktree of the repository.
func (Git) Ignored ¶
Ignored lists the paths git ignores in the checkout; a wholly ignored directory is one entry ending in "/".
func (Git) IsAncestor ¶
IsAncestor reports whether ancestor is reachable from commit. An unknown object counts as not an ancestor.
func (Git) LocalBranchTip ¶
LocalBranchTip is the commit of a local branch, empty when there is none.
func (Git) LsRemote ¶
LsRemote checks that the remote is reachable without prompting, the way launchd would run it.
func (Git) RemoteHasBranch ¶
RemoteHasBranch asks the remote whether branch still exists there.
func (Git) TrackBranch ¶
TrackBranch renames the checkout's current branch to the PR's head branch and tracks it, so tools that find a pull request by branch name find this one. It does nothing when another local branch already has that name.
func (Git) TrackFetchedBranch ¶
TrackFetchedBranch is TrackBranch for a branch FetchPR just fetched as a head.
func (Git) UpstreamBranch ¶
UpstreamBranch returns the remote branch the current branch tracks, or "" when it tracks none.
func (Git) WorktreeAddDetached ¶
WorktreeAddDetached checks out commit in a new worktree at path, on no branch.
type Metered ¶
type Metered struct{ Next Runner }
Metered records one meter.Git sample, a spawn, per command of Next. A run that ends because ctx was canceled is not an error.