Documentation
¶
Index ¶
- func ListVCS() []string
- func RegisterVCS(vcs VersionControlSystem)
- func SetIgnoreUntracked(ignore bool)
- func UnregisterVCS(name string)
- type UntrackedFilter
- type VCSRegistry
- func (r *VCSRegistry) GetActiveVCS() VersionControlSystem
- func (r *VCSRegistry) GetVCS(name string) VersionControlSystem
- func (r *VCSRegistry) ListVCS() []string
- func (r *VCSRegistry) RegisterVCS(vcs VersionControlSystem)
- func (r *VCSRegistry) SetIgnoreUntracked(ignore bool)
- func (r *VCSRegistry) UnregisterVCS(name string)
- type VersionControlSystem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetIgnoreUntracked ¶ added in v0.3.0
func SetIgnoreUntracked(ignore bool)
func UnregisterVCS ¶
func UnregisterVCS(name string)
Types ¶
type UntrackedFilter ¶ added in v0.3.0
type UntrackedFilter interface {
SetIgnoreUntracked(ignore bool)
}
UntrackedFilter is implemented by a VCS that can leave untracked files out of GetUncommittedChanges, GetDirtyFiles and IsWorkingDirectoryClean, so that dirty means what `git describe --dirty` means: staged or unstaged changes to tracked files. The template variables and the release guard both follow it.
type VCSRegistry ¶
type VCSRegistry struct {
// contains filtered or unexported fields
}
VCSRegistry manages available version control systems
func (*VCSRegistry) GetActiveVCS ¶
func (r *VCSRegistry) GetActiveVCS() VersionControlSystem
GetActiveVCS returns the first VCS that detects it's in a repository
func (*VCSRegistry) GetVCS ¶
func (r *VCSRegistry) GetVCS(name string) VersionControlSystem
GetVCS returns a specific VCS by name
func (*VCSRegistry) ListVCS ¶
func (r *VCSRegistry) ListVCS() []string
ListVCS returns all registered VCS names
func (*VCSRegistry) RegisterVCS ¶
func (r *VCSRegistry) RegisterVCS(vcs VersionControlSystem)
RegisterVCS registers a version control system
func (*VCSRegistry) SetIgnoreUntracked ¶ added in v0.3.0
func (r *VCSRegistry) SetIgnoreUntracked(ignore bool)
SetIgnoreUntracked tells every registered VCS that is an UntrackedFilter whether untracked files count as uncommitted changes. A VCS without the capability is passed over.
func (*VCSRegistry) UnregisterVCS ¶
func (r *VCSRegistry) UnregisterVCS(name string)
UnregisterVCS unregisters a version control system
type VersionControlSystem ¶
type VersionControlSystem interface {
// Name returns the name of the VCS (e.g., "git", "svn")
Name() string
// IsRepository checks if we're in a repository of this type
IsRepository() bool
// GetRepositoryRoot returns the root directory of the repository
GetRepositoryRoot() (string, error)
// IsWorkingDirectoryClean checks if there are no uncommitted changes
IsWorkingDirectoryClean() (bool, error)
// GetVCSIdentifier returns a VCS-specific identifier for the current state
GetVCSIdentifier(length int) (string, error)
// CreateTag creates a tag with the specified name and message
CreateTag(tagName, message string) error
// TagExists checks if a tag with the specified name exists
TagExists(tagName string) (bool, error)
// GetTagCommit returns the commit hash that the named tag points to.
// Returns an error if the tag does not exist. The returned hash is the
// full-length identifier (40 chars for git).
GetTagCommit(tagName string) (string, error)
// CreateBranch creates a branch with the specified name from the current HEAD
CreateBranch(branchName string) error
// BranchExists checks if a branch with the specified name exists
BranchExists(branchName string) (bool, error)
// GetBranchCommit returns the commit hash that the named branch points to.
// Returns an error if the branch does not exist.
GetBranchCommit(branchName string) (string, error)
// GetBranchName returns the current branch name
GetBranchName() (string, error)
// GetCommitDate returns the date of the current commit
GetCommitDate() (time.Time, error)
// GetCommitsSinceTag returns the number of commits since the most recent semver tag
// Returns 0 if on a tagged commit, -1 if no tags exist
GetCommitsSinceTag() (int, error)
// GetUncommittedChanges returns the count of uncommitted changes (staged +
// unstaged + untracked; untracked are left out when an UntrackedFilter was
// told to ignore them). Every dirty-derived template variable reads it.
GetUncommittedChanges() (int, error)
// GetLastTag returns the most recent semver tag
// Returns empty string if no matching tags exist
GetLastTag() (string, error)
// GetLastTagCommit returns the SHA of the commit the last tag points to
GetLastTagCommit() (string, error)
// GetCommitAuthor returns the name of the current commit's author
GetCommitAuthor() (string, error)
// GetCommitAuthorEmail returns the email of the current commit's author
GetCommitAuthorEmail() (string, error)
// GetCommitMessagesSinceTag returns all commit messages since the most recent tag
// Returns commit messages newest first, empty slice if on tagged commit or no tags
GetCommitMessagesSinceTag() ([]string, error)
// GetDirtyFiles returns the list of files with uncommitted changes
// Returns relative paths from the repository root
GetDirtyFiles() ([]string, error)
// CommitFiles stages and commits the specified files with the given message
CommitFiles(files []string, message string) error
// AmendCommit stages the specified files and amends the last commit
AmendCommit(files []string) error
// GetHooksPath returns the path to the hooks directory
GetHooksPath() (string, error)
// PushTag pushes a tag to the remote repository
PushTag(tagName string) error
// PushBranch pushes a branch to the remote repository
PushBranch(branchName string) error
}
VersionControlSystem defines the interface for version control operations
func GetActiveVCS ¶
func GetActiveVCS() VersionControlSystem
func GetVCS ¶
func GetVCS(name string) VersionControlSystem