Documentation
¶
Index ¶
- func GetVersionFromTag(tag string) *version.Version
- type Context
- func (gitx *Context) Changes(dir string, absPath bool) ([]string, error)
- func (gitx *Context) ChangesBetweenRevs(dir string, revA, revB string, noRelative bool) ([]string, error)
- func (gitx *Context) CommitContainsTag(ref string, tag string) (bool, error)
- func (gitx *Context) CommitIsAMerge(ref string) (bool, error)
- func (gitx *Context) CurrentRef() (string, error)
- func (gitx *Context) CurrentRev() (string, error)
- func (gitx *Context) FetchUntilCommit(remote string, commitSHA string, opts FetchUntilOpts) (found bool, err error)
- func (gitx *Context) Files(dir string, noRelative bool) ([]string, error)
- func (gitx *Context) HasChanges(dir string) (hasChanges bool, err error)
- func (gitx *Context) IsIgnored(path ...string) (ignored bool, err error)
- func (gitx *Context) IsRefAheadOf(refA string, refB string) (bool, int, error)
- func (gitx *Context) IsRefReachable(fromRef string, ref string) (reachable bool, err error)
- func (gitx *Context) LocalRefExists(ref string) (sha1 string, err error)
- func (gitx *Context) ObjectExists(sha1 string) (exists bool, err error)
- func (gitx *Context) RootDir() (string, error)
- func (gitx *Context) VersionTags(remote string) ([]VersionTag, error)
- type FetchUntilOpts
- type VersionTag
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetVersionFromTag ¶
GetVersionFromTag returns the version if the tag is a release tag (e.g. v1.3.4).
Types ¶
type Context ¶
type Context struct {
*exec.CmdContext
}
func NewCtx ¶
func NewCtx(cwd string, mixin ...func(builder *exec.CmdContextBuilder)) Context
NewCtx returns a new Git command context in the folder `cwd`. Mixin are modifier functions to adapt the ctx to custom needs.
func NewCtxAtRoot ¶
func NewCtxAtRoot( cwd string, mixin ...func(builder *exec.CmdContextBuilder), ) (Context, string, error)
NewCtxAtRoot returns a new Git command context at the root of the Git repo starting from `cwd`. Returns the `rootDir` as well.
func (*Context) Changes ¶
Changes returns all changed paths in `dir` (relative to working dir if its a relative path). Staged files are not returned!
func (*Context) ChangesBetweenRevs ¶
func (gitx *Context) ChangesBetweenRevs( dir string, revA, revB string, noRelative bool, ) ([]string, error)
ChangesBetweenRevs computs path changes between two revision specs, as `git diff revA revB`. You can specify `HEAD~1` and `HEAD` for example. To get absolute paths (relative to the repository) use `noRelative`. To convert all to absolute paths use `fs.MakeAllAbsolute`.
func (*Context) CommitContainsTag ¶
CommitContainsTag returns `true` if the commit (ref) `ref` contains the tag `tag`.
func (*Context) CommitIsAMerge ¶
Check if the current commit is a merge commit.
func (*Context) CurrentRef ¶
CurrentRef returns the current Git symbolic reference (branch). e.g. `feat/bla`.
func (*Context) CurrentRev ¶
CurrentRev returns the current revision SHA1.
func (*Context) FetchUntilCommit ¶
func (gitx *Context) FetchUntilCommit( remote string, commitSHA string, opts FetchUntilOpts, ) (found bool, err error)
FetchUntilCommit fetches exponentially increasing the shallow boundary of the remote (`*4`) until the `commitSHA` is found in `git rev-list `. Only tries until `maxDepth` has been reached. Meaningful values are: `factor = 4`, `startDepth = 10`, `maxDepth = 1000`.
func (*Context) HasChanges ¶
HasChanges reports if there any unstaged changes in repository.
func (*Context) IsRefAheadOf ¶
IsRefAheadOf checks if ref `refB` is ahead of `refA` and by how many commits. Returns `false` and `0` if `refB` is not ahead of `refA`.
func (*Context) IsRefReachable ¶
IsRefReachable reports if `ref` (can be branch/tag/commit) is contained starting from `fromRef`.
func (*Context) LocalRefExists ¶
Checks if a local branch `ref` exists and returns the SHA1.
func (*Context) ObjectExists ¶
ObjectExists checks if an object in Git addressed by the SHA1 `sha1` exists.
func (*Context) RootDir ¶
RootDir returns the top level directory inside `cwd`. If in a submodule it returns the submodule root directory.
func (*Context) VersionTags ¶
func (gitx *Context) VersionTags(remote string) ([]VersionTag, error)
VersionTags returns all versions from existing Git version tags (e.g. `v1.2.3`) in descendin order (sem. version).