Documentation
¶
Overview ¶
Package git provides a high-level interface for interacting with a Git subprocess.
Index ¶
- type AddOptions
- type AmendOptions
- type BranchOptions
- type CheckoutConflictBehavior
- type CheckoutOptions
- type CommitInfo
- type CommitOptions
- type Config
- func (cfg *Config) Bool(name string) (bool, error)
- func (cfg *Config) Color(name string, default_ string) ([]byte, error)
- func (cfg *Config) ColorBool(name string, isTerm bool) (bool, error)
- func (cfg *Config) CommentChar() (string, error)
- func (cfg *Config) ListRemotes() map[string]*Remote
- func (cfg *Config) Value(name string) string
- type DiffStatusCode
- type DiffStatusEntry
- type DiffStatusOptions
- type FetchRefspec
- type Git
- func (g *Git) AbortMerge(ctx context.Context) error
- func (g *Git) Add(ctx context.Context, pathspecs []Pathspec, opts AddOptions) error
- func (g *Git) Amend(ctx context.Context, opts AmendOptions) error
- func (g *Git) AmendAll(ctx context.Context, opts AmendOptions) error
- func (g *Git) AmendFiles(ctx context.Context, pathspecs []Pathspec, opts AmendOptions) error
- func (g *Git) Cat(ctx context.Context, rev string, path TopPath) (io.ReadCloser, error)
- func (g *Git) CheckoutBranch(ctx context.Context, branch string, opts CheckoutOptions) error
- func (g *Git) CheckoutRev(ctx context.Context, rev string, opts CheckoutOptions) error
- func (g *Git) Command(ctx context.Context, args ...string) *exec.Cmd
- func (g *Git) Commit(ctx context.Context, message string, opts CommitOptions) error
- func (g *Git) CommitAll(ctx context.Context, message string, opts CommitOptions) error
- func (g *Git) CommitFiles(ctx context.Context, message string, pathspecs []Pathspec, opts CommitOptions) error
- func (g *Git) CommitInfo(ctx context.Context, rev string) (*CommitInfo, error)
- func (g *Git) CommonDir(ctx context.Context) (string, error)
- func (g *Git) DiffStatus(ctx context.Context, opts DiffStatusOptions) ([]DiffStatusEntry, error)
- func (g *Git) GitDir(ctx context.Context) (string, error)
- func (g *Git) Head(ctx context.Context) (*Rev, error)
- func (g *Git) HeadRef(ctx context.Context) (Ref, error)
- func (g *Git) Init(ctx context.Context, dir string) error
- func (g *Git) InitBare(ctx context.Context, dir string) error
- func (g *Git) IsAncestor(ctx context.Context, rev1, rev2 string) (bool, error)
- func (g *Git) IsMerging(ctx context.Context) (bool, error)
- func (g *Git) ListRefs(ctx context.Context) (map[Ref]Hash, error)
- func (g *Git) ListRefsVerbatim(ctx context.Context) (map[Ref]Hash, error)
- func (g *Git) ListRemoteRefs(ctx context.Context, remote string) (map[Ref]Hash, error)
- func (g *Git) ListTree(ctx context.Context, rev string, pathspecs []Pathspec) (map[TopPath]struct{}, error)
- func (g *Git) Log(ctx context.Context, opts LogOptions) (*Log, error)
- func (g *Git) Merge(ctx context.Context, revs []string) error
- func (g *Git) MergeBase(ctx context.Context, rev1, rev2 string) (Hash, error)
- func (g *Git) MutateRefs(ctx context.Context, muts map[Ref]RefMutation) error
- func (g *Git) NewBranch(ctx context.Context, name string, opts BranchOptions) error
- func (g *Git) NullTreeHash(ctx context.Context) (Hash, error)
- func (g *Git) Output(ctx context.Context, args ...string) (string, error)
- func (g *Git) ParseRev(ctx context.Context, refspec string) (*Rev, error)
- func (g *Git) Path() string
- func (g *Git) ReadConfig(ctx context.Context) (*Config, error)
- func (g *Git) Remove(ctx context.Context, pathspecs []Pathspec, opts RemoveOptions) error
- func (g *Git) Run(ctx context.Context, args ...string) error
- func (g *Git) StageTracked(ctx context.Context) error
- func (g *Git) Status(ctx context.Context, opts StatusOptions) ([]StatusEntry, error)
- func (g *Git) WithDir(dir string) *Git
- func (g *Git) WorkTree(ctx context.Context) (string, error)
- type Hash
- type Log
- type LogOptions
- type Options
- type Pathspec
- type PathspecMagic
- type Ref
- type RefMutation
- type RefPattern
- type Remote
- type RemoveOptions
- type Rev
- type StatusCode
- func (code StatusCode) IsAdded() bool
- func (code StatusCode) IsCopied() bool
- func (code StatusCode) IsIgnored() bool
- func (code StatusCode) IsMissing() bool
- func (code StatusCode) IsModified() bool
- func (code StatusCode) IsOriginalMissing() bool
- func (code StatusCode) IsRemoved() bool
- func (code StatusCode) IsRenamed() bool
- func (code StatusCode) IsUnmerged() bool
- func (code StatusCode) IsUntracked() bool
- func (code StatusCode) String() string
- type StatusEntry
- type StatusOptions
- type TopPath
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddOptions ¶
type AddOptions struct { // IncludeIgnored specifies whether to add ignored files. // If this is false and an ignored file is explicitly named, then Add // will return an error while other matched files are still added. IncludeIgnored bool // If IntentToAdd is true, then contents of files in the index will // not be changed, but any untracked files will have entries added // into the index with empty content. IntentToAdd bool }
AddOptions specifies the command-line options for `git add`.
type AmendOptions ¶
type AmendOptions struct { // If Message is not empty, it is the commit message that will be used. // Otherwise, the previous commit's message will be used. Message string // If Author is filled out, then it will be used as the commit author. // If Author is the zero value, then the previous commit's author will // be used. If Author is partially filled out, the Amend methods will // return an error. Author User // If AuthorTime is not zero, then it will be used as the author time. // Otherwise, the previous commit's author time will be used. AuthorTime time.Time // Committer fields set to non-zero values will override the default // committer information from Git configuration. Committer User // If CommitTime is not zero, then it will be used as the commit time // instead of now. CommitTime time.Time }
AmendOptions overrides the previous commit's fields.
type BranchOptions ¶
type BranchOptions struct { // StartPoint is a revision to start from. If empty, then HEAD is used. StartPoint string // If Checkout is true, then HEAD and the working copy will be // switched to the new branch. Checkout bool // If Overwrite is true and a branch with the given name already // exists, then it will be reset to the start point. No other branch // information is modified, like the upstream. Overwrite bool // If Track is true and StartPoint names a ref, then the upstream of // the branch will be set to the ref named by StartPoint. Track bool }
BranchOptions specifies options for a new branch.
type CheckoutConflictBehavior ¶
type CheckoutConflictBehavior int
CheckoutConflictBehavior specifies the behavior of checkout with local modifications.
const ( // AbortOnFileChange stops the checkout if a file that is modified // locally differs between the current HEAD and the target commit. // This is the default behavior. AbortOnFileChange CheckoutConflictBehavior = iota // MergeLocal performs a three-way merge on any differing files. MergeLocal // DiscardLocal uses the target commit's content regardless of local // modifications. DiscardLocal )
Possible checkout behaviors when encountering locally modified files.
func (CheckoutConflictBehavior) String ¶
func (ccb CheckoutConflictBehavior) String() string
String returns the Go constant name of the behavior.
type CheckoutOptions ¶
type CheckoutOptions struct { // ConflictBehavior specifies the behavior when encountering locally // modified files. ConflictBehavior CheckoutConflictBehavior }
CheckoutOptions specifies the command-line options for `git checkout`.
type CommitInfo ¶
type CommitInfo struct { Hash Hash Parents []Hash Author User Committer User AuthorTime time.Time CommitTime time.Time Message string }
CommitInfo stores information about a single commit.
type CommitOptions ¶
CommitOptions overrides the default metadata for a commit. Any fields with zero values will use the value inferred from Git's environment.
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is a collection of configuration settings.
func (*Config) Bool ¶
Bool returns the boolean configuration setting with the given name.
func (*Config) Color ¶
Color returns the ANSI escape sequence for the given configuration setting.
func (*Config) ColorBool ¶
ColorBool finds the color configuration setting is true or false. isTerm indicates whether the eventual output will be a terminal.
func (*Config) CommentChar ¶
CommentChar returns the value of the `core.commentChar` setting.
func (*Config) ListRemotes ¶
ListRemotes returns the names of all remotes specified in the configuration.
type DiffStatusCode ¶
type DiffStatusCode byte
DiffStatusCode is a single-letter code from the `git diff --name-status` format.
See https://git-scm.com/docs/git-diff#git-diff---diff-filterACDMRTUXB82308203 for a description of each of the codes.
const ( DiffStatusAdded DiffStatusCode = 'A' DiffStatusCopied DiffStatusCode = 'C' DiffStatusDeleted DiffStatusCode = 'D' DiffStatusModified DiffStatusCode = 'M' DiffStatusRenamed DiffStatusCode = 'R' DiffStatusChangedMode DiffStatusCode = 'T' DiffStatusUnmerged DiffStatusCode = 'U' DiffStatusUnknown DiffStatusCode = 'X' DiffStatusBroken DiffStatusCode = 'B' )
Diff status codes.
func (DiffStatusCode) String ¶
func (code DiffStatusCode) String() string
String returns the code letter as a string.
type DiffStatusEntry ¶
type DiffStatusEntry struct { Code DiffStatusCode Name TopPath }
A DiffStatusEntry describes the state of a single file in a diff.
type DiffStatusOptions ¶
type DiffStatusOptions struct { // Commit1 specifies the earlier commit to compare with. If empty, // then DiffStatus compares against the index. Commit1 string // Commit2 specifies the later commit to compare with. If empty, then // DiffStatus compares against the working tree. Callers must not set // Commit2 if Commit1 is empty. Commit2 string // Pathspecs filters the output to the given pathspecs. Pathspecs []Pathspec // DisableRenames will force Git to disable rename/copy detection. DisableRenames bool }
DiffStatusOptions specifies the command-line arguments for `git diff --status`.
type FetchRefspec ¶
type FetchRefspec string
A FetchRefspec specifies a mapping from remote refs to local refs.
func (FetchRefspec) Map ¶
func (spec FetchRefspec) Map(remote Ref) Ref
Map maps a remote ref into a local ref. If there is no mapping, then Map returns an empty Ref.
func (FetchRefspec) Parse ¶
func (spec FetchRefspec) Parse() (src, dst RefPattern, plus bool)
Parse parses the refspec into its parts.
func (FetchRefspec) String ¶
func (spec FetchRefspec) String() string
String returns the refspec as a string.
type Git ¶
type Git struct {
// contains filtered or unexported fields
}
Git is a context for performing Git version control operations. Broadly, it consists of a path to an installed copy of Git and a working directory path.
func New ¶
New creates a new Git context.
func (*Git) AbortMerge ¶
AbortMerge aborts the current conflict resolution process and tries to reconstruct pre-merge state.
func (*Git) Add ¶
Add adds file contents to the index.
func (*Git) Amend ¶
func (g *Git) Amend(ctx context.Context, opts AmendOptions) error
Amend replaces the tip of the current branch with a new commit with the content of the index.
func (*Git) AmendAll ¶
func (g *Git) AmendAll(ctx context.Context, opts AmendOptions) error
AmendAll replaces the tip of the current branch with a new commit with the content of the working copy for all tracked files.
func (*Git) AmendFiles ¶
AmendFiles replaces the tip of the current branch with a new commit with the content of the named files from the working copy. Files not named will get their content from the previous commit.
Notably, AmendFiles with no paths will not change the file content of the commit, just the options specified.
func (*Git) Cat ¶
Cat reads the content of a file at a particular revision. It is the caller's responsibility to close the returned io.ReadCloser if the returned error is nil.
func (*Git) CheckoutBranch ¶
CheckoutBranch switches HEAD to another branch and updates the working copy to match. If the branch does not exist, then CheckoutBranch returns an error.
func (*Git) CheckoutRev ¶
CheckoutRev switches HEAD to a specific commit and updates the working copy to match. It will always put the worktree in "detached HEAD" state.
func (*Git) Command ¶
Command creates a new *exec.Cmd that will invoke Git with the given arguments. The returned command does not obey the given Context's deadline or cancelation.
func (*Git) Commit ¶
Commit creates a new commit on HEAD with the staged content. The message will be used exactly as given.
func (*Git) CommitAll ¶
CommitAll creates a new commit on HEAD with all of the tracked files. The message will be used exactly as given.
func (*Git) CommitFiles ¶
func (g *Git) CommitFiles(ctx context.Context, message string, pathspecs []Pathspec, opts CommitOptions) error
CommitFiles creates a new commit on HEAD that updates the given files to the content in the working copy. The message will be used exactly as given.
func (*Git) CommitInfo ¶
CommitInfo obtains information about a single commit.
func (*Git) CommonDir ¶
CommonDir determines the absolute path of the Git directory, possibly shared among different working trees, given the configuration. Any symlinks are resolved.
func (*Git) DiffStatus ¶
func (g *Git) DiffStatus(ctx context.Context, opts DiffStatusOptions) ([]DiffStatusEntry, error)
DiffStatus compares the working copy with a commit using `git diff --name-status`.
See https://git-scm.com/docs/git-diff#git-diff---name-status for more details.
func (*Git) GitDir ¶
GitDir determines the absolute path of the Git directory for this working tree given the configuration. Any symlinks are resolved.
func (*Git) Head ¶
Head returns the working copy's branch revision. If the branch does not point to a valid commit (such as when the repository is first created), then Head returns an error.
func (*Git) HeadRef ¶
HeadRef returns the working copy's branch. If the working copy is in detached HEAD state, then HeadRef returns an empty string and no error. The ref may not point to a valid commit.
func (*Git) Init ¶
Init ensures a repository exists at the given path. Any relative paths are interpreted relative to the Git process's working directory. If any of the repository's parent directories don't exist, they will be created.
func (*Git) InitBare ¶
InitBare ensures a bare repository exists at the given path. Any relative paths are interpreted relative to the Git process's working directory. If any of the repository's parent directories don't exist, they will be created.
func (*Git) IsAncestor ¶
IsAncestor reports whether rev1 is an ancestor of rev2. If rev1 == rev2, then IsAncestor returns true.
func (*Git) IsMerging ¶
IsMerging reports whether the index has a pending merge commit.
func (*Git) ListRefs ¶
ListRefs lists all of the refs in the repository with tags dereferenced.
func (*Git) ListRefsVerbatim ¶ added in v1.0.0
ListRefsVerbatim lists all of the refs in the repository. Tags will not be dereferenced.
func (*Git) ListRemoteRefs ¶
ListRemoteRefs lists all of the refs in a remote repository. remote may be a URL or the name of a remote.
This function may block on user input if the remote requires credentials.
func (*Git) ListTree ¶
func (g *Git) ListTree(ctx context.Context, rev string, pathspecs []Pathspec) (map[TopPath]struct{}, error)
ListTree returns the list of files at a given revision. If pathspecs is not empty, then it is used to filter the paths.
func (*Git) Log ¶
Log starts fetching information about a set of commits. The context's deadline and cancelation will apply to the entire read from the Log.
func (*Git) Merge ¶
Merge merges changes from the named revisions into the index and the working copy. It updates MERGE_HEAD but does not create a commit. Merge will never perform a fast-forward merge.
In case of conflict, Merge will return an error but still update MERGE_HEAD. To check for this condition, call IsMerging after receiving an error from Merge (verifying that IsMerging returned false before calling Merge).
func (*Git) MergeBase ¶
MergeBase returns the best common ancestor between two commits to use in a three-way merge.
func (*Git) MutateRefs ¶ added in v1.0.0
MutateRefs atomically modifies zero or more refs. If there are no non-zero mutations, then MutateRefs returns nil without running Git.
func (*Git) NewBranch ¶
NewBranch creates a new branch, a ref of the form "refs/heads/NAME", where NAME is the name argument.
func (*Git) NullTreeHash ¶ added in v1.0.0
NullTreeHash computes the hash of an empty tree and adds it to the repository. This is sometimes useful as a diff comparison target.
func (*Git) Output ¶
Output runs Git with the given arguments and returns its stdout.
func (*Git) ParseRev ¶
ParseRev parses a revision.
func (*Git) Path ¶
Path returns the absolute path to the Git executable.
func (*Git) ReadConfig ¶
ReadConfig reads all the configuration settings from Git.
func (*Git) Remove ¶
Remove removes file contents from the index.
func (*Git) Run ¶
Run runs Git with the given arguments. If an error occurs, the combined stdout and stderr will be returned in the error.
func (*Git) StageTracked ¶
StageTracked updates the index to match the tracked files in the working copy.
func (*Git) Status ¶
func (g *Git) Status(ctx context.Context, opts StatusOptions) ([]StatusEntry, error)
Status returns any differences the working copy has from the files at HEAD.
func (*Git) WithDir ¶
WithDir returns a new instance that is changed to use dir as its working directory. Any relative paths will be interpreted relative to g's working directory.
type Hash ¶
type Hash [hashSize]byte
A Hash is the SHA-1 hash of a Git object.
func (Hash) Short ¶
Short returns the first 4 hex-encoded bytes of the hash.
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
Log is an open handle to a `git log` subprocess. Closing the Log stops the subprocess.
func (*Log) Close ¶
Close ends the log subprocess and waits for it to finish. Close returns an error if Next returned false due to a parse failure.
func (*Log) CommitInfo ¶
func (l *Log) CommitInfo() *CommitInfo
CommitInfo returns the most recently scanned log entry. Next must be called at least once before calling CommitInfo.
type LogOptions ¶
type LogOptions struct { // Revs specifies the set of commits to list. When empty, it defaults // to all commits reachable from HEAD. Revs []string // MaxParents sets an inclusive upper limit on the number of parents // on revisions to return from Log. If MaxParents is zero, then it is // treated as no limit unless AllowZeroMaxParents is true. MaxParents int AllowZeroMaxParents bool // If FirstParent is true, then follow only the first parent commit // upon seeing a merge commit. FirstParent bool // Limit specifies the upper bound on the number of revisions to return from Log. // Zero means no limit. Limit int // If Reverse is true, then commits will be returned in reverse order. Reverse bool }
LogOptions specifies filters and ordering on a log listing.
type Options ¶
type Options struct { // LogHook is a function that will be called at the start of every Git // subprocess. LogHook func(ctx context.Context, args []string) // Env specifies the environment of the subprocess. // If len(Env) == 0, then no environment variables will be set. Env []string }
Options specifies optional parameters to New.
type Pathspec ¶
type Pathspec string
A Pathspec is a Git path pattern. It will be passed through literally to Git.
const NoPathspec Pathspec = ":"
NoPathspec is the special "there is no pathspec" form. If present, it should be the only pathspec in a list of pathspecs.
func JoinPathspecMagic ¶
func JoinPathspecMagic(magic PathspecMagic, pattern string) Pathspec
JoinPathspecMagic combines a set of magic options and a pattern into a pathspec.
func LiteralPath ¶
LiteralPath escapes a string from any special characters.
func (Pathspec) SplitMagic ¶
func (p Pathspec) SplitMagic() (PathspecMagic, string)
SplitMagic splits the pathspec into the magic signature and the pattern. Unrecognized options are ignored, so this is a lossy operation.
type PathspecMagic ¶
type PathspecMagic struct { Top bool Literal bool CaseInsensitive bool Glob bool AttributeRequirements []string Exclude bool }
PathspecMagic specifies all the "magic" pathspec options. See pathspec under gitglossary(7) for more details.
func (PathspecMagic) IsZero ¶
func (magic PathspecMagic) IsZero() bool
IsZero reports whether all the fields are unset.
func (PathspecMagic) String ¶
func (magic PathspecMagic) String() string
String returns the magic in long form like ":(top,literal)". The zero value returns ":()".
type Ref ¶
type Ref string
A Ref is a Git reference to a commit.
const ( // Head names the commit on which the changes in the working tree // are based. Head Ref = "HEAD" // FetchHead records the branch which was fetched from a remote // repository with the last git fetch invocation. FetchHead Ref = "FETCH_HEAD" )
Top-level refs.
func TagRef ¶ added in v1.0.0
TagRef returns a ref for the given tag name.
func (Ref) Branch ¶
Branch returns the string after "refs/heads/" or an empty string if the ref does not start with "refs/heads/".
func (Ref) IsBranch ¶
IsBranch reports whether r starts with "refs/heads/".
type RefMutation ¶ added in v1.0.0
type RefMutation struct {
// contains filtered or unexported fields
}
A RefMutation describes an operation to perform on a ref. The zero value is a no-op.
func DeleteRef ¶ added in v1.0.0
func DeleteRef() RefMutation
DeleteRef returns a RefMutation that unconditionally deletes a ref.
func DeleteRefIfMatches ¶ added in v1.0.0
func DeleteRefIfMatches(oldvalue string) RefMutation
DeleteRefIfMatches returns a RefMutation that attempts to delete a ref, but fails if it has the given value.
func (RefMutation) String ¶ added in v1.0.0
func (mut RefMutation) String() string
String returns the mutation in a form similar to a line of input to `git update-ref --stdin`.
type RefPattern ¶
type RefPattern string
A RefPattern is a part of a refspec. It may be either a literal suffix match (e.g. "main" matches "refs/head/main"), or the last component may be a wildcard ('*'), which indicates a prefix match.
func (RefPattern) Match ¶
func (pat RefPattern) Match(ref Ref) (suffix string, ok bool)
Match reports whether a ref matches the pattern. If the pattern is a prefix match, then suffix is the string matched by the wildcard.
func (RefPattern) Prefix ¶
func (pat RefPattern) Prefix() (_ string, ok bool)
Prefix returns the prefix before the wildcard if it's a wildcard pattern. Otherwise it returns "", false.
type Remote ¶
type Remote struct { Name string FetchURL string Fetch []FetchRefspec PushURL string }
Remote stores the configuration for a remote repository.
func (*Remote) MapFetch ¶
MapFetch maps a remote fetch ref into a local ref. If there is no mapping, then MapFetch returns an empty Ref.
type RemoveOptions ¶
type RemoveOptions struct { // Recursive specifies whether to remove directories. Recursive bool // If Modified is true, then files will be deleted even if they've // been modified from their checked in state. Modified bool // If KeepWorkingCopy is true, then the file will only be removed in // the index, not the working copy. KeepWorkingCopy bool }
RemoveOptions specifies the command-line options for `git add`.
type Rev ¶
Rev is a parsed reference to a single commit.
type StatusCode ¶
type StatusCode [2]byte
A StatusCode is a two-letter code from the `git status` short format. For paths with no merge conflicts, the first letter is the status of the index and the second letter is the status of the work tree.
More details at https://git-scm.com/docs/git-status#_short_format
func (StatusCode) IsAdded ¶
func (code StatusCode) IsAdded() bool
IsAdded reports whether the file is new to the index (including copies, but not renames).
func (StatusCode) IsCopied ¶
func (code StatusCode) IsCopied() bool
IsCopied reports whether the file has been copied from elsewhere.
func (StatusCode) IsIgnored ¶
func (code StatusCode) IsIgnored() bool
IsIgnored returns true if the file is being ignored by Git.
func (StatusCode) IsMissing ¶
func (code StatusCode) IsMissing() bool
IsMissing reports whether the file has been deleted in the work tree.
func (StatusCode) IsModified ¶
func (code StatusCode) IsModified() bool
IsModified reports whether the file has been modified in either the index or the work tree.
func (StatusCode) IsOriginalMissing ¶
func (code StatusCode) IsOriginalMissing() bool
IsOriginalMissing reports whether the file has been detected as a rename in the work tree, but neither this file or its original have been updated in the index. If IsOriginalMissing is true, then IsAdded returns true.
func (StatusCode) IsRemoved ¶
func (code StatusCode) IsRemoved() bool
IsRemoved reports whether the file has been deleted in the index.
func (StatusCode) IsRenamed ¶
func (code StatusCode) IsRenamed() bool
IsRenamed reports whether the file is the result of a rename.
func (StatusCode) IsUnmerged ¶
func (code StatusCode) IsUnmerged() bool
IsUnmerged reports whether the file has unresolved merge conflicts.
func (StatusCode) IsUntracked ¶
func (code StatusCode) IsUntracked() bool
IsUntracked returns true if the file is not being tracked by Git.
func (StatusCode) String ¶
func (code StatusCode) String() string
String returns the code's bytes as a string.
type StatusEntry ¶
type StatusEntry struct { // Code is the two-letter code from the Git status short format. // More details in the Output section of git-status(1). Code StatusCode // Name is the path of the file. Name TopPath // From is the path of the file that this file was renamed or // copied from, otherwise an empty string. From TopPath }
A StatusEntry describes the state of a single file in the working copy.
func (StatusEntry) String ¶
func (ent StatusEntry) String() string
String returns the entry in short format.
type StatusOptions ¶
type StatusOptions struct { // IncludeIgnored specifies whether to emit ignored files. IncludeIgnored bool // DisableRenames will force Git to disable rename/copy detection. DisableRenames bool // Pathspecs filters the output to the given pathspecs. Pathspecs []Pathspec }
StatusOptions specifies the command-line arguments for `git status`.
type TopPath ¶
type TopPath string
A TopPath is a slash-separated path relative to the top level of the repository.
func (TopPath) Pathspec ¶
Pathspec converts a top-level path to a pathspec.
type User ¶
type User struct { // Name is the user's full name. Name string // Email is the user's email address. Email string }
User identifies an author or committer.
func (User) String ¶
String returns the user information as a string in the form "User Name <[email protected]>".