Documentation ¶
Index ¶
- Variables
- func CurrentCommit() (commit string, err error)
- func EnsureBranchInRepository(path string, branchName string) error
- func EnsureBranchInRepositoryCmd(path string, branchName string) magelib.Cmd
- func FormatStatusError(path string, status *StatusInfo) error
- func GitStatusOutput(cwd string) (io.Reader, error)
- func IsCommitTagged(commit string) (bool, error)
- func IsInsideWorkTree(cwd string) (bool, error)
- func IsRepoClean(path string) error
- func IsRepoCleanCmd(path string) magelib.Cmd
- func MostRecentTag() (tag string, err error)
- func PathToGitDir(cwd string) (string, error)
- func TagsByCommit(commit string) ([]string, error)
- type GitArea
- type GitRepository
- type StatusInfo
Constants ¶
This section is empty.
Variables ¶
var ( Checkout = sh.RunCmd("git", "checkout") Branch = sh.OutCmd("git", "rev-parse", "--abbrev-ref", "HEAD") )
var Email = "unknown@github"
var (
ErrCommitNotDefined = errors.New("commit not defined")
)
var ErrNotAGitRepo = errors.New("not a git repo")
var Name = "Repo Maintainer"
Functions ¶
func CurrentCommit ¶
CurrentCommit retrieves the current commit hash of the Git repository.
It returns the commit hash as a string and an error if the command fails.
func EnsureBranchInRepository ¶
EnsureBranchInRepository ensures that a branch is checked out in a repository.
It takes two parameters: - path (string): the path to the repository. - branchName (string): the name of the branch to ensure.
It returns an error if there was a problem ensuring the branch.
func EnsureBranchInRepositoryCmd ¶
EnsureBranchInRepositoryCmd returns a function that ensures that a branch is checked out in a repository.
The function takes two parameters: - path (string): the path to the repository. - branchName (string): the name of the branch to ensure.
It returns a function that, when called, ensures the specified branch exists in the repository. The returned function returns an error if there was a problem ensuring the branch.
func FormatStatusError ¶
func FormatStatusError(path string, status *StatusInfo) error
func IsCommitTagged ¶
IsCommitTagged checks if a commit is tagged in a Git repository.
It takes a commit hash string as a parameter and returns a boolean indicating whether the commit is tagged and an error.
func IsInsideWorkTree ¶
func IsRepoClean ¶
func IsRepoCleanCmd ¶
func MostRecentTag ¶
MostRecentTag retrieves the current tag of a Git repository at the specified path.
It takes a path string as a parameter and returns a string representing the current tag and an error.
func PathToGitDir ¶
func TagsByCommit ¶
TagsByCommit retrieves the tags associated with a given commit in a Git repository.
It takes a commit string as a parameter and returns a slice of strings representing the tags and an error. The commit string should not be empty. If it is, the function returns an error with the value ErrCommitNotDefined. The function executes the "git tag --contains <commit> --sort=-creatordate" command to retrieve the tags. If the command fails, the function returns an error. The function splits the output of the command into tags using the newline character as a delimiter. If the output contains only an empty string, the function returns an empty slice. Otherwise, it returns the slice of tags.
Types ¶
type GitRepository ¶
type GitRepository struct {
// contains filtered or unexported fields
}
func NewGitRepository ¶
func NewGitRepository(repoPath, repoURL string) (*GitRepository, error)
func (*GitRepository) CommitAll ¶
func (p *GitRepository) CommitAll(message string) error
type StatusInfo ¶
type StatusInfo struct { Unstaged GitArea Staged GitArea // contains filtered or unexported fields }
func GitStatus ¶
func GitStatus(path string) (*StatusInfo, error)
func NewStatusInfo ¶
func NewStatusInfo(path string) *StatusInfo
func (*StatusInfo) Debug ¶
func (pi *StatusInfo) Debug() string
Debug retrieves StatusInfo as string
func (*StatusInfo) IsDirty ¶
func (pi *StatusInfo) IsDirty() bool
IsDirty returns true if staged files have changed
func (*StatusInfo) IsModified ¶
func (pi *StatusInfo) IsModified() bool
IsDirty returns true if unstaged files have changed
func (*StatusInfo) IsSynced ¶
func (pi *StatusInfo) IsSynced() bool
IsSynced returns true if repo is in sync with remote