git

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package git provides functions for interacting with git repositories by shelling out to the git CLI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommitDate

func CommitDate(repoPath, branch string) (time.Time, error)

CommitDate returns the author date of the latest commit on the given branch.

func CurrentBranch

func CurrentBranch(repoPath string) (string, error)

CurrentBranch returns the name of the currently checked-out branch.

func DefaultBranch

func DefaultBranch(repoPath string) (string, error)

DefaultBranch returns the default branch name (main or master) by checking what the origin HEAD points to, falling back to a local heuristic.

func DeleteLocalBranch

func DeleteLocalBranch(repoPath, branch string, force bool) error

DeleteLocalBranch deletes a local branch. If force is true, uses -D instead of -d.

func DeleteRemoteBranch

func DeleteRemoteBranch(repoPath, remote, branch string) error

DeleteRemoteBranch deletes a branch on the given remote.

func Fetch

func Fetch(repoPath, remote string) error

Fetch fetches from the given remote.

func HasRemote

func HasRemote(repoPath, remote string) bool

HasRemote returns true if the given remote exists.

func IsClean

func IsClean(repoPath string) (bool, error)

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

func IsMerged

func IsMerged(repoPath, branch, base string) (bool, error)

IsMerged returns true if the given branch has been merged into base.

func IsRepo

func IsRepo(path string) bool

IsRepo returns true if the given path is inside a git repository.

func ListBranches

func ListBranches(repoPath string) ([]string, error)

ListBranches returns all local branch names.

func MergedBranches

func MergedBranches(repoPath, base string) ([]string, error)

MergedBranches returns local branches that have been merged into the given base branch.

func RemoteURL

func RemoteURL(repoPath, remote string) (string, error)

RemoteURL returns the fetch URL of the given remote (usually "origin").

Types

This section is empty.

Jump to

Keyboard shortcuts

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