git

package
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 8, 2026 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMaxCommitDepth = 10000

DefaultMaxCommitDepth is the maximum number of commits to walk when searching for tags

Variables

This section is empty.

Functions

func CreateTag

func CreateTag(tagName, message string) error

CreateTag creates a git tag with the specified name and message

func GetGitShortHash

func GetGitShortHash(hashLength int) (string, error)

GetGitShortHash returns the short hash of the current HEAD commit with specified length

func GetHashLength

func GetHashLength() int

GetHashLength returns the configured hash length from config file or environment variable Priority: 1) Config file, 2) VERSIONATOR_HASH_LENGTH env var, 3) Default (7)

func GetHashLengthFromConfig

func GetHashLengthFromConfig(configHashLength int) int

GetHashLengthFromConfig returns hash length from config, with fallback to environment/default

func IsGitRepository

func IsGitRepository() bool

IsGitRepository checks if we're in a git repository

func IsWorkingDirectoryClean

func IsWorkingDirectoryClean() (bool, error)

IsWorkingDirectoryClean checks if the git working directory is clean (no uncommitted changes)

func TagExists

func TagExists(tagName string) (bool, error)

TagExists checks if a git tag with the specified name already exists

Types

type GitVersionControlSystem

type GitVersionControlSystem struct {
	// contains filtered or unexported fields
}

GitVersionControlSystem implements VersionControlSystem for Git

func NewGitVCS

func NewGitVCS() *GitVersionControlSystem

NewGitVCS creates a new GitVersionControlSystem

func (*GitVersionControlSystem) CreateTag

func (g *GitVersionControlSystem) CreateTag(tagName, message string) error

CreateTag creates a git tag

func (*GitVersionControlSystem) GetBranchName

func (g *GitVersionControlSystem) GetBranchName() (string, error)

GetBranchName returns the current branch name

func (*GitVersionControlSystem) GetCommitAuthor

func (g *GitVersionControlSystem) GetCommitAuthor() (string, error)

GetCommitAuthor returns the name of the current commit's author

func (*GitVersionControlSystem) GetCommitAuthorEmail

func (g *GitVersionControlSystem) GetCommitAuthorEmail() (string, error)

GetCommitAuthorEmail returns the email of the current commit's author

func (*GitVersionControlSystem) GetCommitDate

func (g *GitVersionControlSystem) GetCommitDate() (time.Time, error)

GetCommitDate returns the date of the current commit

func (*GitVersionControlSystem) GetCommitsSinceTag

func (g *GitVersionControlSystem) GetCommitsSinceTag() (int, error)

GetCommitsSinceTag returns the number of commits since the most recent tag Returns 0 if on a tagged commit, -1 if no tags exist

func (*GitVersionControlSystem) GetLastTag

func (g *GitVersionControlSystem) GetLastTag() (string, error)

GetLastTag returns the most recent semver tag Returns empty string if no tags exist

func (*GitVersionControlSystem) GetLastTagCommit

func (g *GitVersionControlSystem) GetLastTagCommit() (string, error)

GetLastTagCommit returns the SHA of the commit the last tag points to

func (*GitVersionControlSystem) GetRepositoryRoot

func (g *GitVersionControlSystem) GetRepositoryRoot() (string, error)

GetRepositoryRoot returns the root directory of the git repository

func (*GitVersionControlSystem) GetTemplateVariables

func (g *GitVersionControlSystem) GetTemplateVariables(context map[string]string) map[string]string

GetTemplateVariables returns git-specific template variables

func (*GitVersionControlSystem) GetUncommittedChanges

func (g *GitVersionControlSystem) GetUncommittedChanges() (int, error)

GetUncommittedChanges returns the count of uncommitted changes (staged + unstaged + untracked)

func (*GitVersionControlSystem) GetVCSIdentifier

func (g *GitVersionControlSystem) GetVCSIdentifier(length int) (string, error)

GetVCSIdentifier returns a short hash of the current commit

func (*GitVersionControlSystem) IsRepository

func (g *GitVersionControlSystem) IsRepository() bool

IsRepository checks if we're in a git repository

func (*GitVersionControlSystem) IsWorkingDirectoryClean

func (g *GitVersionControlSystem) IsWorkingDirectoryClean() (bool, error)

IsWorkingDirectoryClean checks if there are no uncommitted changes

func (*GitVersionControlSystem) Name

func (g *GitVersionControlSystem) Name() string

Name returns "git"

func (*GitVersionControlSystem) TagExists

func (g *GitVersionControlSystem) TagExists(tagName string) (bool, error)

TagExists checks if a tag exists

func (*GitVersionControlSystem) Types

Types returns the set of plugin types this VCS implements

type TagInfo

type TagInfo struct {
	CommitsSinceTag   int    // -1 if no tags exist
	LastTagName       string // empty if no tags
	LastTagCommitHash string // empty if no tags
}

TagInfo holds pre-computed tag-related information from a single walk

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL