git

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package git provides git repository operations using go-git.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidSemver

func IsValidSemver(version string) bool

IsValidSemver checks if a version string is valid semver. Accepts versions with or without 'v' prefix.

func NormalizeVersion

func NormalizeVersion(version string) string

NormalizeVersion ensures the version string has a 'v' prefix.

func ParseRemoteURL

func ParseRemoteURL(url string) (owner, repo string)

ParseRemoteURL extracts owner and repo from various git URL formats. Supports:

func ParseVersion

func ParseVersion(tag string) string

ParseVersion extracts version from a tag, stripping the leading 'v' if present.

Types

type Repository

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

Repository wraps go-git repository operations.

func Open

func Open(path string) (*Repository, error)

Open opens the git repository at the given path. If path is empty or ".", it opens the repository in the current directory. It will search parent directories for a .git folder.

func (*Repository) GetCurrentBranch

func (r *Repository) GetCurrentBranch() (string, error)

GetCurrentBranch returns the name of the current branch.

func (*Repository) GetHeadCommit

func (r *Repository) GetHeadCommit() (string, error)

GetHeadCommit returns the full SHA of the commit at HEAD.

func (*Repository) GetHeadCommitTime added in v0.2.0

func (r *Repository) GetHeadCommitTime() (time.Time, error)

GetHeadCommitTime returns the committer timestamp of the commit at HEAD.

func (*Repository) GetLatestReachableTag

func (r *Repository) GetLatestReachableTag() (string, error)

GetLatestReachableTag returns the most recent semver tag reachable from HEAD, including tags on ancestor commits. This is similar to `git describe --tags --abbrev=0`.

func (*Repository) GetLatestTag

func (r *Repository) GetLatestTag() (string, error)

GetLatestTag returns the most recent semver tag reachable from HEAD. Returns empty string if no valid semver tags are found.

func (*Repository) GetOwnerRepo

func (r *Repository) GetOwnerRepo() (owner, repo string, err error)

GetOwnerRepo extracts owner and repo from the origin remote URL.

func (*Repository) GetRemoteURL

func (r *Repository) GetRemoteURL() (string, error)

GetRemoteURL returns the URL of the "origin" remote.

func (*Repository) HasUncommittedChanges

func (r *Repository) HasUncommittedChanges() (bool, error)

HasUncommittedChanges returns true if there are staged or unstaged changes.

func (*Repository) IsClean

func (r *Repository) IsClean() (bool, error)

IsClean returns true if the working tree has no uncommitted changes.

Jump to

Keyboard shortcuts

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