git

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlobContent

func BlobContent(ref Ref, path string, repoDir string) ([]byte, bool, error)

func CommitDiff

func CommitDiff(hash, repoDir string) (string, error)

func IsBinary

func IsBinary(b []byte) bool

IsBinary performs a heuristic check to determine if data is binary. Rules:

  • Any NUL byte => binary
  • Consider only a sample (up to 8 KiB). If >30% of bytes are control characters outside the common whitespace/newline range, treat as binary.

func ParseFileMode

func ParseFileMode(modeStr string) (string, error)

ParseFileMode converts a git-style file mode (e.g. "100644") into a human-readable string like "rw-r--r--".

func RefToFileName added in v1.0.1

func RefToFileName(ref string) string

Types

type Blob

type Blob struct {
	Ref      Ref
	Mode     string
	Path     string
	FileName string
	Size     int64
}

func Files

func Files(ref Ref, repoDir string) ([]Blob, error)

type Commit

type Commit struct {
	Hash      string
	ShortHash string
	Subject   string
	Body      string
	Author    string
	Email     string
	Date      time.Time
	Parents   []string
	Branch    Ref
	RefNames  []RefName
	Href      string
}

func Commits

func Commits(ref Ref, repoDir string) ([]Commit, error)

type Ref

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

func Branches

func Branches(repoDir string, filter *regexp.Regexp, defaultBranch string) ([]Ref, error)

func NewRef added in v1.0.1

func NewRef(ref string) Ref

func (Ref) DirName added in v1.0.1

func (r Ref) DirName() string

func (Ref) IsEmpty added in v1.0.1

func (r Ref) IsEmpty() bool

func (Ref) String added in v1.0.1

func (r Ref) String() string

type RefKind

type RefKind string
const (
	RefKindHEAD       RefKind = "HEAD"
	RefKindRemoteHEAD RefKind = "RemoteHEAD"
	RefKindBranch     RefKind = "Branch"
	RefKindRemote     RefKind = "Remote"
	RefKindTag        RefKind = "Tag"
)

type RefName

type RefName struct {
	Kind   RefKind
	Name   string // Name is the primary name of the ref as shown by `git log %D` token (left side for pointers)
	Target string // Target is set for symbolic refs like "HEAD -> main" or "origin/HEAD -> origin/main"
}

type Tag

type Tag struct {
	Name       string
	Date       time.Time
	CommitHash string
}

func Tags

func Tags(repoDir string) ([]Tag, error)

Jump to

Keyboard shortcuts

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