gitutil

package
v0.0.0-...-ec59030 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package gitutil — centralized date display formatting.

Package gitutil extracts Git metadata by running git commands.

Package gitutil — latest-branch core operations.

Package gitutil — latest-branch resolve operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckOnline

func CheckOnline() error

CheckOnline verifies network connectivity by dialing a remote host.

func CurrentBranch

func CurrentBranch(repoPath string) (string, error)

CurrentBranch returns the current branch name for a repo.

func FetchAll

func FetchAll(repoPath string)

FetchAll runs git fetch --all --prune for a repo (best effort).

func FetchAllPrune

func FetchAllPrune() error

FetchAllPrune runs git fetch --all --prune.

func FilterByPattern

func FilterByPattern(refs []string, pattern string) []string

FilterByPattern keeps only refs whose branch name matches the given glob or substring pattern.

func FilterByRemote

func FilterByRemote(refs []string, remote string) []string

FilterByRemote keeps only refs starting with "<remote>/".

func FormatDisplayDate

func FormatDisplayDate(t time.Time) string

FormatDisplayDate converts a time.Time to the local time zone and returns a human-friendly string: DD-Mon-YYYY hh:mm AM/PM.

func FormatDisplayDateUTC

func FormatDisplayDateUTC(t time.Time) string

FormatDisplayDateUTC converts a time.Time to UTC and returns a human-friendly string: DD-Mon-YYYY hh:mm AM/PM (UTC).

func IsInsideWorkTree

func IsInsideWorkTree() bool

IsInsideWorkTree checks if the current directory is inside a git repo.

func IsOnline

func IsOnline() bool

IsOnline returns true if network connectivity is available.

func ListRemoteBranches

func ListRemoteBranches() ([]string, error)

ListRemoteBranches returns trimmed remote-tracking branch names, excluding HEAD pointer lines.

func PrintOfflineWarning

func PrintOfflineWarning()

PrintOfflineWarning prints a user-friendly offline message.

func RemoteURL

func RemoteURL(repoPath string) (string, error)

RemoteURL returns the origin remote URL for a repo at the given path.

func ResolveContains

func ResolveContains(sha, remote string) []string

ResolveContains returns branch names whose history contains sha.

func ResolvePointsAt

func ResolvePointsAt(sha, remote string) []string

ResolvePointsAt returns branch names that point exactly at sha.

func SortByDateDesc

func SortByDateDesc(items []RemoteBranchInfo)

SortByDateDesc sorts items by CommitDate descending.

func SortByNameAsc

func SortByNameAsc(items []RemoteBranchInfo)

SortByNameAsc sorts items by branch name ascending.

func StripRemotePrefix

func StripRemotePrefix(ref string) string

StripRemotePrefix removes the "<remote>/" prefix from a ref.

func TruncSha

func TruncSha(sha string) string

TruncSha returns the first N characters of a SHA for display.

Types

type RemoteBranchInfo

type RemoteBranchInfo struct {
	RemoteRef  string
	CommitDate time.Time
	Sha        string
	Subject    string
}

RemoteBranchInfo holds commit metadata for a remote-tracking branch.

func ReadBranchTips

func ReadBranchTips(refs []string) ([]RemoteBranchInfo, error)

ReadBranchTips reads commit metadata for each remote ref.

type RepoStatus

type RepoStatus struct {
	Branch      string
	Dirty       bool
	Untracked   int
	Modified    int
	Staged      int
	Ahead       int
	Behind      int
	StashCount  int
	Unreachable bool
}

RepoStatus holds the live state of a Git repository.

func Status

func Status(repoPath string) RepoStatus

Status returns the full live status of a repository. If the path does not exist or is not a git repo, Unreachable is set.

Jump to

Keyboard shortcuts

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