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) CalculatePreRelease(ctx context.Context, channel, bumpType string) (*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) GetTagCommit(ctx context.Context, tag string) (string, 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) LatestStableTag(ctx context.Context) (string, error)
- func (t *Tagger) LatestTag(ctx context.Context) (string, error)
- func (t *Tagger) ListAllTags(ctx context.Context) ([]TagInfo, error)
- func (t *Tagger) MoveTag(ctx context.Context, tag, target, message string) error
- func (t *Tagger) ParseLatestStableVersion(ctx context.Context) (*version.Version, 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) PushTagForce(ctx context.Context, tag string) error
- func (t *Tagger) ResolveCommit(ctx context.Context, ref string) (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) CalculatePreRelease ¶ added in v1.3.0
func (t *Tagger) CalculatePreRelease(ctx context.Context, channel, bumpType string) (*version.Version, error)
CalculatePreRelease computes the next prerelease version for a SemVer tag.
channel is the prerelease identifier (e.g., "alpha", "beta", "rc"). Pass "release" to graduate the current prerelease to a stable version. bumpType ("major", "minor", "patch") is required when the latest tag is stable and channel is not "release".
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) GetTagCommit ¶ added in v1.3.0
GetTagCommit returns the full commit hash that the given tag points to. For annotated tags, it dereferences the tag object to the underlying commit.
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) LatestStableTag ¶ added in v1.3.0
LatestStableTag returns the most recent tag that is a stable (non-prerelease) SemVer version. It iterates over all matching tags (git-sorted, newest first) and returns the first one whose parsed version has no prerelease identifier. Returns an empty string if no stable tags are found.
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) MoveTag ¶ added in v1.3.0
MoveTag force-moves an existing tag to the target commit-ish. Uses git tag -f -a to preserve the annotated tag format. Respects the dry-run flag.
func (*Tagger) ParseLatestStableVersion ¶ added in v1.3.0
ParseLatestStableVersion returns the parsed stable version from the latest stable tag. Returns nil if no stable tags exist.
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) PushTagForce ¶ added in v1.3.0
PushTagForce force-pushes the tag to the remote repository. Use this after MoveTag to update the remote ref. Respects the dry-run flag.
func (*Tagger) ResolveCommit ¶ added in v1.3.0
ResolveCommit resolves any ref (commit hash, branch name, HEAD, etc.) to a full commit hash.
func (*Tagger) ShortCommit ¶
ShortCommit returns the short commit hash (first 7 characters).