git

package
v1.0.58 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsMainBranch added in v1.0.21

func IsMainBranch(currentBranch string, mainBranches []string) bool

IsMainBranch checks if the given branch name matches any of the main branches

func SanitizeBranchName

func SanitizeBranchName(branch string) string

SanitizeBranchName converts a branch name to a valid prerelease identifier

func StripTagPrefix

func StripTagPrefix(tag, prefix string) string

StripTagPrefix removes the configured prefix from a tag name

Types

type Repo

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

Repo represents a git repository

func OpenRepo

func OpenRepo(path string) (*Repo, error)

OpenRepo opens a git repository at the given path

func (*Repo) CheckMainBranchHasNewCommitsSinceBranchPoint added in v1.0.43

func (g *Repo) CheckMainBranchHasNewCommitsSinceBranchPoint(mainBranch, currentBranch string) (bool, error)

CheckMainBranchHasNewCommitsSinceBranchPoint checks if main branch has any new commits after the current branch diverged from it. Returns true if main has moved forward since the branch point. This is useful for detecting if a feature branch is outdated regardless of tags.

func (*Repo) CheckMainBranchHasNewTagsSinceBranchPoint added in v1.0.43

func (g *Repo) CheckMainBranchHasNewTagsSinceBranchPoint(mainBranch, currentBranch string) (bool, string, error)

CheckMainBranchHasNewTagsSinceBranchPoint checks if main branch has been tagged after the current branch diverged from it. Returns true if main has new tags, along with the most recent tag name on main if found.

func (*Repo) GetCommitCount

func (g *Repo) GetCommitCount() (int, error)

GetCommitCount returns the number of commits on the current branch

func (*Repo) GetCommitCountSinceBranchPoint

func (g *Repo) GetCommitCountSinceBranchPoint(mainBranch, currentBranch string) (int, error)

GetCommitCountSinceBranchPoint returns the number of commits since branching from main This uses a proper merge-base algorithm to find the common ancestor

func (*Repo) GetCurrentBranch

func (g *Repo) GetCurrentBranch() (string, error)

GetCurrentBranch returns the name of the current branch

func (*Repo) GetMainBranch added in v1.0.21

func (g *Repo) GetMainBranch(mainBranches []string) (string, error)

GetMainBranch returns the first main branch that exists in the repository It checks both local and remote branches to handle detached HEAD states in CI

func (*Repo) GetMainBranchCommitCount

func (g *Repo) GetMainBranchCommitCount(mainBranch string) (int, error)

GetMainBranchCommitCount returns the commit count on the main branch It checks both local and remote branches to handle detached HEAD states in CI

func (*Repo) GetMainBranchCommitsSinceBranchPoint added in v1.0.41

func (g *Repo) GetMainBranchCommitsSinceBranchPoint(mainBranch, currentBranch string) (int, error)

GetMainBranchCommitsSinceBranchPoint returns the number of commits on main branch since the point where the current branch diverged from main

func (*Repo) GetMostRecentTag added in v1.0.14

func (g *Repo) GetMostRecentTag(tagPrefix string) (string, int, error)

GetMostRecentTag returns the most recent tag that is reachable from HEAD Only tags that are in the current branch's history (merged) are considered If tagPrefix is provided, only tags with that prefix are considered Returns the tag name and commits since that tag (0 if we're on the tag) The "most recent" tag is determined by highest semantic version, not by commit date

func (*Repo) GetTagOnCurrentCommit

func (g *Repo) GetTagOnCurrentCommit() (string, error)

GetTagOnCurrentCommit returns the tag on the current HEAD commit, if any When multiple tags point to the same commit, it returns the one with the highest semantic version

func (*Repo) IsShallow added in v1.0.20

func (g *Repo) IsShallow() (bool, error)

IsShallow checks if the repository is a shallow clone

func (*Repo) IsTagInHistory added in v1.0.53

func (g *Repo) IsTagInHistory(tagName string) (bool, error)

IsTagInHistory checks if a tag is reachable from HEAD (i.e., merged into current branch) Returns true if the tag is in the current branch's ancestry

Jump to

Keyboard shortcuts

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