git

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiscoverLatestTag

func DiscoverLatestTag(repo *git.Repository, firstParent bool) (*version.Version, string, error)

DiscoverLatestTag finds the most recent semver tag in the repository if firstParent is true, only considers tags that are ancestors of HEAD via first-parent

func GetCommitsSinceTag

func GetCommitsSinceTag(repo *git.Repository, tagName string, toRef string, firstParent bool) ([]*object.Commit, error)

GetCommitsSinceTag returns all commits since the given tag (or from beginning if tagName is empty) if firstParent is true, only follows first parent in merge commits toRef specifies the target ref (defaults to HEAD if empty)

When tagName is non-empty and resolves to a commit that the walk from toRef never actually reaches (reversed range, divergent range, or -- in firstParent mode -- a stop commit only reachable via a merged-in side branch), this returns an empty slice and a nil error instead of the full history: git's two-dot A..B semantics mean an unreachable A yields nothing, not everything. A warning is printed to stderr in that case.

func GetRepositoryName

func GetRepositoryName(repo *git.Repository) string

GetRepositoryName attempts to extract the repository name from remote URL

func OpenRepository

func OpenRepository(path string) (*git.Repository, error)

OpenRepository opens a git repository at the given path.

If the fast path (git.PlainOpen) fails because a branch in the repository's config has a merge ref outside refs/heads/ (e.g. the refs/pull/<n>/head that `gh pr checkout` writes, which real git accepts but go-git's config parser rejects -- see sanitize.go), it retries by sanitizing that config in memory and reopening through go-git's lower-level Open. Any failure in that retry falls back to the original PlainOpen error, never a confusing error from the workaround path itself.

func ParseCommits

func ParseCommits(commits []*object.Commit) []version.ParsedCommit

ParseCommits converts git commits to ParsedCommits non-conventional commits are included with Type="other"

func ParseRepoNameFromURL

func ParseRepoNameFromURL(url string) string

ParseRepoNameFromURL extracts owner/repo from a git URL returns "unknown" if parsing fails to avoid leaking raw URLs

Types

This section is empty.

Jump to

Keyboard shortcuts

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