Documentation
¶
Overview ¶
Package git provides git repository operations using go-git.
Index ¶
- func IsValidSemver(version string) bool
- func NormalizeVersion(version string) string
- func ParseRemoteURL(url string) (owner, repo string)
- func ParseVersion(tag string) string
- type Repository
- func (r *Repository) GetCommitForTag(tag string) (string, error)
- func (r *Repository) GetCurrentBranch() (string, error)
- func (r *Repository) GetHeadCommit() (string, error)
- func (r *Repository) GetHeadCommitTime() (time.Time, error)
- func (r *Repository) GetLatestReachableTag() (string, error)
- func (r *Repository) GetLatestTag() (string, error)
- func (r *Repository) GetOwnerRepo() (owner, repo string, err error)
- func (r *Repository) GetRemoteURL() (string, error)
- func (r *Repository) HasUncommittedChanges() (bool, error)
- func (r *Repository) IsClean() (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsValidSemver ¶
IsValidSemver checks if a version string is valid semver. Accepts versions with or without 'v' prefix.
func NormalizeVersion ¶
NormalizeVersion ensures the version string has a 'v' prefix.
func ParseRemoteURL ¶
ParseRemoteURL extracts owner and repo from various git URL formats. Supports:
- SSH format: git@github.com:owner/repo.git
- HTTPS format: https://github.com/owner/repo.git
- HTTP format: http://github.com/owner/repo.git
func ParseVersion ¶
ParseVersion extracts version from a tag, stripping the leading 'v' if present.
Types ¶
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository wraps go-git repository operations.
func Open ¶
func Open(path string) (*Repository, error)
Open opens the git repository at the given path. If path is empty or ".", it opens the repository in the current directory. It will search parent directories for a .git folder.
func (*Repository) GetCommitForTag ¶ added in v0.8.0
func (r *Repository) GetCommitForTag(tag string) (string, error)
GetCommitForTag resolves a tag to the full SHA of the commit it points at. Annotated tag objects are peeled to their target commit, so lightweight and annotated tags resolve identically.
func (*Repository) GetCurrentBranch ¶
func (r *Repository) GetCurrentBranch() (string, error)
GetCurrentBranch returns the name of the current branch.
func (*Repository) GetHeadCommit ¶
func (r *Repository) GetHeadCommit() (string, error)
GetHeadCommit returns the full SHA of the commit at HEAD.
func (*Repository) GetHeadCommitTime ¶ added in v0.2.0
func (r *Repository) GetHeadCommitTime() (time.Time, error)
GetHeadCommitTime returns the committer timestamp of the commit at HEAD.
func (*Repository) GetLatestReachableTag ¶
func (r *Repository) GetLatestReachableTag() (string, error)
GetLatestReachableTag returns the most recent semver tag reachable from HEAD, including tags on ancestor commits. This is similar to `git describe --tags --abbrev=0`.
func (*Repository) GetLatestTag ¶
func (r *Repository) GetLatestTag() (string, error)
GetLatestTag returns the most recent semver tag reachable from HEAD. Returns empty string if no valid semver tags are found.
func (*Repository) GetOwnerRepo ¶
func (r *Repository) GetOwnerRepo() (owner, repo string, err error)
GetOwnerRepo extracts owner and repo from the origin remote URL.
func (*Repository) GetRemoteURL ¶
func (r *Repository) GetRemoteURL() (string, error)
GetRemoteURL returns the URL of the "origin" remote.
func (*Repository) HasUncommittedChanges ¶
func (r *Repository) HasUncommittedChanges() (bool, error)
HasUncommittedChanges returns true if there are staged or unstaged changes.
func (*Repository) IsClean ¶
func (r *Repository) IsClean() (bool, error)
IsClean returns true if the working tree has no uncommitted changes.