git

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TagInfo

type TagInfo struct {
	Tag     string
	Version string
	Commit  string
	Date    string
	Message string
}

TagInfo represents information about a version tag.

type Tagger

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

Tagger handles git tag operations.

func NewTagger

func NewTagger(repoDir, prefix string, dryRun bool) *Tagger

NewTagger creates a new Tagger for the given repository directory.

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

func (t *Tagger) CommitVersionUpdate(ctx context.Context, filePath, version string) error

CommitVersionUpdate commits a version file update (like package.json). It stages the file, creates a commit with a standard message.

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

func (t *Tagger) CreateTag(ctx context.Context, tag, message string) error

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

func (t *Tagger) CurrentCommit(ctx context.Context) (string, error)

CurrentCommit returns the current commit hash.

func (*Tagger) GetTagInfo

func (t *Tagger) GetTagInfo(ctx context.Context, tagName string) (*TagInfo, error)

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

func (t *Tagger) GetVersionWithDirtyCheck(ctx context.Context) (string, error)

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

func (t *Tagger) HasUncommittedChanges(ctx context.Context) (bool, error)

HasUncommittedChanges checks if there are uncommitted changes in the repository.

func (*Tagger) IsTagOnCurrentCommit

func (t *Tagger) IsTagOnCurrentCommit(ctx context.Context, tag string) (bool, error)

IsTagOnCurrentCommit checks if the given tag points to the current commit.

func (*Tagger) LatestTag

func (t *Tagger) LatestTag(ctx context.Context) (string, error)

LatestTag returns the latest tag with the configured prefix, or empty string if none exists.

func (*Tagger) ListAllTags

func (t *Tagger) ListAllTags(ctx context.Context) ([]TagInfo, error)

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

func (t *Tagger) PushTag(ctx context.Context, tag string) error

PushTag pushes the tag to the remote repository. If dryRun is true, only logs the operation without pushing.

func (*Tagger) ShortCommit

func (t *Tagger) ShortCommit(ctx context.Context) (string, error)

ShortCommit returns the short commit hash (first 7 characters).

func (*Tagger) TagExists

func (t *Tagger) TagExists(ctx context.Context, tag string) (bool, error)

TagExists checks if a tag already exists.

Jump to

Keyboard shortcuts

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