Documentation
¶
Overview ¶
Package git asks git about the work tree a folder is in: its top, its common git folder, its remotes, the work trees and other repos it holds, the folders it doesn't track or ignores, and the files that differ between commits.
Index ¶
- Variables
- type Client
- func (c Client) Applies(ctx context.Context, dir, patch string) ([]string, error)
- func (c Client) Changed(ctx context.Context, dir, rev string, specs []string) ([]string, error)
- func (c Client) CommonDir(ctx context.Context, dir string) (string, error)
- func (c Client) Differs(ctx context.Context, dir, rng string, specs []string) ([]string, error)
- func (c Client) Gitlinks(ctx context.Context, dir string) ([]string, error)
- func (c Client) IgnoredFolders(ctx context.Context, dir string) ([]string, error)
- func (c Client) IsCommit(ctx context.Context, dir, rev string) (bool, error)
- func (c Client) Others(ctx context.Context, dir string, specs []string) ([]string, error)
- func (c Client) Rebases(ctx context.Context, dir, rev string) (bool, error)
- func (c Client) Remotes(ctx context.Context, dir string) ([]Remote, error)
- func (c Client) TopLevel(ctx context.Context, dir string) (string, error)
- func (c Client) Tops(ctx context.Context, dir string) (top, common string, err error)
- func (c Client) Tracks(ctx context.Context, dir, spec string) (bool, error)
- func (c Client) Tree(ctx context.Context, dir, rev string, specs []string) ([]string, error)
- func (c Client) Unstaged(ctx context.Context, dir string, specs []string) ([]string, error)
- func (c Client) Untracked(ctx context.Context, dir string, specs []string) ([]string, error)
- func (c Client) UntrackedFolders(ctx context.Context, dir string) ([]string, error)
- func (c Client) WorkTrees(ctx context.Context, dir string) ([]string, error)
- type Error
- type Remote
- type Runner
Constants ¶
This section is empty.
Variables ¶
var ErrAmbiguous = errors.New("a name git reads as more than one ref")
ErrAmbiguous is returned, wrapped, for a question naming a ref that names more than one, which git answers for one while a command may take another.
var ErrNoFolder = errors.New("no such folder")
ErrNoFolder is returned, wrapped, for a folder that doesn't exist, where git can't run.
var ErrNotInstalled = errors.New("git isn't on the PATH; install git")
ErrNotInstalled is returned, wrapped, when git isn't on the PATH.
var ErrNotRepository = errors.New("not in a git work tree")
ErrNotRepository is returned, wrapped, for a folder in no git work tree.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
Runner Runner
// Environ is terrace's own environment, as os.Environ gives it. git
// sees only what it needs of it: nothing that could point it at another
// repo, as GIT_DIR or GIT_CEILING_DIRECTORIES would.
Environ []string
}
Client runs git through Runner.
func (Client) Applies ¶
Applies are the files the patch file patch touches, as git apply reads them, by their paths from the top of the work tree. git names a file by the name the patch leaves it, so a rename's source is the name its reverse leaves.
func (Client) Changed ¶
Changed are the files of specs whose content the work tree changes from the commit rev, which a move that discards its changes, or a restore from rev, writes.
func (Client) CommonDir ¶
CommonDir is the git folder every worktree of dir's repo shares, as an absolute path.
func (Client) Differs ¶
Differs are the files of specs that differ across rng, a revision range, which a move across it writes.
func (Client) Gitlinks ¶
Gitlinks are the other repos dir's work tree holds, by their absolute paths, as its index records them: each submodule, checked out or not, and a checkout added with no .gitmodules entry. dir is the top of the work tree, which git names them from.
func (Client) IgnoredFolders ¶
IgnoredFolders are the folders of dir's work tree git lists ignored, by their absolute paths: a folder wholly ignored, or holding only what's ignored, is one, which git doesn't look inside, so a repo inside it isn't listed apart. dir is the top of the work tree, which git names them from.
func (Client) IsCommit ¶
IsCommit reports whether rev names a commit. It's peeled with ^0, not ^{commit}: git reads stash@{0}^3^{commit}, where stash@{0} has no third parent, as stash@{0} at a date its reflog gives, a commit.
func (Client) Rebases ¶
Rebases reports whether a pull onto the branch rev names rebases, as git's config says: the branch's own rebase setting, else pull.rebase, anything but false; false where neither is set. A rev that names no branch takes pull.rebase alone.
func (Client) TopLevel ¶
TopLevel is the top of the work tree holding dir. A dir in no work tree is ErrNotRepository.
func (Client) Tops ¶
Tops are the top of the work tree holding dir, and the git folder every worktree of its repo shares, as an absolute path, both from one call. A dir in no work tree is ErrNotRepository.
func (Client) Tree ¶
Tree are the files of specs the commit rev holds, compared with no commit at all, as a commit with no parent is: a stash's untracked files.
func (Client) Unstaged ¶
Unstaged are the files of specs whose content the work tree changes from the index, which a restore from the index writes.
func (Client) UntrackedFolders ¶
UntrackedFolders are the folders of dir's work tree git lists untracked, by their absolute paths: git lists each untracked file, but stops at a repo of its own, which it lists as a folder, however deep in untracked folders it lies. dir is the top of the work tree, which git names them from.
type Error ¶
type Error struct {
Dir string
Args []string
Stderr string
Err error
// contains filtered or unexported fields
}
Error is a git call that failed: where it ran, what git said, and the run's error.
func (*Error) Error ¶
Error names the call, the folder it ran in, and what git said, then each error joined in the run's error, a line apiece, but the runner's exit where git exited by itself, which its words explain: a signal's end is kept. Where git said nothing, the run's error is given whole.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package gittest runs real git for tests, in an environment of the test's own, so the person's git config can't reach it, and gives the folders git names, by their physical paths.
|
Package gittest runs real git for tests, in an environment of the test's own, so the person's git config can't reach it, and gives the folders git names, by their physical paths. |