git

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const NotesRef = "remarks"

NotesRef is the git notes reference used for remarks

Variables

View Source
var ErrDetachedHead = errors.New("not on a branch (detached HEAD)")

ErrDetachedHead is returned when the repository is in detached HEAD state

Functions

func FindCommitByPatchID

func FindCommitByPatchID(patchID, startCommit string, limit int) (string, error)

FindCommitByPatchID searches for a commit with matching patch-id in the given range

func GetAncestors

func GetAncestors(commit string, limit int) ([]string, error)

GetAncestors returns all ancestor commits from the given commit up to the specified limit (0 = no limit)

func GetAncestorsUpTo

func GetAncestorsUpTo(start, end string) ([]string, error)

GetAncestorsUpTo returns all ancestor commits from start to end (exclusive)

func GetCurrentBranch

func GetCurrentBranch() (string, error)

GetCurrentBranch returns the current branch name

func GetGitDir

func GetGitDir() (string, error)

GetGitDir returns the .git directory path

func GetHEAD

func GetHEAD() (string, error)

GetHEAD returns the current HEAD commit SHA

func GetPatchID

func GetPatchID(commit string) (string, error)

GetPatchID computes the patch-id for a commit

func GetRepoRoot

func GetRepoRoot() (string, error)

GetRepoRoot returns the root directory of the git repository

func GetShortSHA

func GetShortSHA(commit string) (string, error)

GetShortSHA returns the short SHA for a commit

func IsAncestor

func IsAncestor(ancestor, descendant string) (bool, error)

IsAncestor returns true if ancestor is an ancestor of descendant

func IsDetachedHead

func IsDetachedHead() bool

IsDetachedHead returns true if the repository is in detached HEAD state

func IsInsideWorkTree

func IsInsideWorkTree() bool

IsInsideWorkTree checks if the current directory is inside a git repository

func Run

func Run(args ...string) (string, error)

Run executes a git command and returns the output

func RunWithStdin

func RunWithStdin(stdin string, args ...string) (string, error)

RunWithStdin executes a git command with stdin input

Types

type CommitInfo

type CommitInfo struct {
	SHA      string
	ShortSHA string
	Subject  string
}

CommitInfo contains basic information about a commit

func GetCommitLog

func GetCommitLog(commit string, limit int) ([]CommitInfo, error)

GetCommitLog returns a list of commits with their short SHAs and subjects

Jump to

Keyboard shortcuts

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