Documentation
¶
Index ¶
- func ExtractTagFromBranch(branchName, prefix string) (string, error)
- func GetCurrentBranch(repoDir string) (string, error)
- func IsHotfixBranch(branchName, prefix string) bool
- func ListBranches(repoDir string) ([]string, error)
- func ValidateHotfixBaseTag(ctx context.Context, repoDir, tag string) error
- func ValidateWorkingTreeClean(ctx context.Context, repoDir string) error
- type TagInfo
- type Tagger
- func (t *Tagger) CalculateNextVersion(ctx context.Context, scheme version.Scheme, bump version.BumpType, ...) (*version.Version, error)
- func (t *Tagger) CommitVersionUpdate(ctx context.Context, filePath, version string) error
- func (t *Tagger) CreateHotfixBranch(ctx context.Context, tag, branchPrefix string, checkout bool) (string, error)
- func (t *Tagger) CreateHotfixTag(ctx context.Context, tag, message string) error
- func (t *Tagger) CreateNextTag(ctx context.Context, scheme version.Scheme, bump version.BumpType, ...) (string, error)
- func (t *Tagger) CreateTag(ctx context.Context, tag, message string) error
- func (t *Tagger) CurrentCommit(ctx context.Context) (string, error)
- func (t *Tagger) GetNextHotfixTag(ctx context.Context, baseTag, suffix string) (string, int, error)
- func (t *Tagger) GetTagInfo(ctx context.Context, tagName string) (*TagInfo, error)
- func (t *Tagger) GetVersionWithDirtyCheck(ctx context.Context) (string, error)
- func (t *Tagger) HasUncommittedChanges(ctx context.Context) (bool, error)
- func (t *Tagger) IsTagOnCurrentCommit(ctx context.Context, tag string) (bool, error)
- func (t *Tagger) LatestTag(ctx context.Context) (string, error)
- func (t *Tagger) ListAllTags(ctx context.Context) ([]TagInfo, error)
- func (t *Tagger) ParseLatestVersion(ctx context.Context, scheme version.Scheme) (*version.Version, error)
- func (t *Tagger) PushTag(ctx context.Context, tag string) error
- func (t *Tagger) ShortCommit(ctx context.Context) (string, error)
- func (t *Tagger) TagExists(ctx context.Context, tag string) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractTagFromBranch ¶ added in v1.3.0
ExtractTagFromBranch extracts the base tag from hotfix branch name. Example: "release/api/v1.0.0" with prefix "release/" → "api/v1.0.0"
func GetCurrentBranch ¶ added in v1.3.0
GetCurrentBranch returns the currently checked out branch name.
func IsHotfixBranch ¶ added in v1.3.0
IsHotfixBranch checks if current branch matches hotfix pattern.
func ListBranches ¶ added in v1.3.0
ListBranches returns all branches in the repository.
func ValidateHotfixBaseTag ¶ added in v1.3.0
ValidateHotfixBaseTag ensures tag is valid for hotfix creation.
Types ¶
type Tagger ¶
type Tagger struct {
// contains filtered or unexported fields
}
Tagger handles git tag operations.
func (*Tagger) CalculateNextVersion ¶
func (t *Tagger) CalculateNextVersion(ctx context.Context, scheme version.Scheme, bump version.BumpType, calverFormat, pre, meta string) (*version.Version, error)
CalculateNextVersion calculates the next version without creating a tag. This is useful when you need to know the version before making changes (e.g., updating package.json).
func (*Tagger) CommitVersionUpdate ¶
CommitVersionUpdate commits a version file update (like package.json). It stages the file, creates a commit with a standard message.
func (*Tagger) CreateHotfixBranch ¶ added in v1.3.0
func (t *Tagger) CreateHotfixBranch(ctx context.Context, tag, branchPrefix string, checkout bool) (string, error)
CreateHotfixBranch creates a new hotfix branch from specified tag.
func (*Tagger) CreateHotfixTag ¶ added in v1.3.0
CreateHotfixTag creates a hotfix tag from current HEAD.
func (*Tagger) CreateNextTag ¶
func (t *Tagger) CreateNextTag(ctx context.Context, scheme version.Scheme, bump version.BumpType, calverFormat, pre, meta string) (string, error)
CreateNextTag generates the next tag based on the scheme and creates it. For semver, bump is required. For calver, the current date is used.
func (*Tagger) CreateTag ¶
CreateTag creates an annotated tag with the given name and message. If dryRun is true, only logs the operation without creating the tag.
func (*Tagger) CurrentCommit ¶
CurrentCommit returns the current commit hash.
func (*Tagger) GetNextHotfixTag ¶ added in v1.3.0
GetNextHotfixTag determines next hotfix version from base tag. Example: base "v1.0.0", existing "v1.0.0-hotfix.2" → returns "v1.0.0-hotfix.3", seq 3
func (*Tagger) GetTagInfo ¶
GetTagInfo retrieves detailed information for a specific tag. It handles prefix auto-detection by trying both the exact tag name and with the configured prefix. Returns TagInfo with all fields populated, or an error if the tag doesn't exist.
func (*Tagger) GetVersionWithDirtyCheck ¶
GetVersionWithDirtyCheck returns the version string, appending "-dirty-<short-commit>" if there are uncommitted changes or if the latest tag is not on the current commit. If no tags exist, it returns "0.0.0-dev".
func (*Tagger) HasUncommittedChanges ¶
HasUncommittedChanges checks if there are uncommitted changes in the repository.
func (*Tagger) IsTagOnCurrentCommit ¶
IsTagOnCurrentCommit checks if the given tag points to the current commit.
func (*Tagger) LatestTag ¶
LatestTag returns the latest tag with the configured prefix, or empty string if none exists.
func (*Tagger) ListAllTags ¶
ListAllTags returns all tags with the configured prefix, sorted by version (newest first). For each tag, it includes the commit hash, date, and message.
func (*Tagger) ParseLatestVersion ¶
func (t *Tagger) ParseLatestVersion(ctx context.Context, scheme version.Scheme) (*version.Version, error)
ParseLatestVersion returns the parsed version of the latest tag, or nil if no tag exists.
func (*Tagger) PushTag ¶
PushTag pushes the tag to the remote repository. If dryRun is true, only logs the operation without pushing.
func (*Tagger) ShortCommit ¶
ShortCommit returns the short commit hash (first 7 characters).