gitutil

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GitState

type GitState struct {
	// Date is the current commit datetime.
	Date time.Time
	// IsDirty indicates whether there are uncommitted changes.
	IsDirty bool
	// IsRepo indicates whether the directory is a Git repository.
	IsRepo bool
	// SHA is the full SHA-1 (40 characters) of the current commit.
	SHA string
}

GitState contains information about the Git repository state.

func InspectGitState

func InspectGitState(dir string) (GitState, error)

InspectGitState inspects the Git repo state from the specified directory. If the directory is not a Git repository, or if git utility is not available, returns GitState with IsRepo=false and no error.

func (*GitState) ShortSHA

func (s *GitState) ShortSHA(length int) string

ShortSHA returns a truncated SHA with the specified length. If length is negative, zero, or greater than the SHA length, it returns the full SHA. Returns empty string if SHA is empty.

Jump to

Keyboard shortcuts

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