git

package
v0.0.0-...-a188cfd Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommitWithTags

type CommitWithTags struct {
	Commit *object.Commit
	Tags   []string
}

CommitWithTags groups a commit with the tag names that point directly to it. Tags is nil for most commits.

type Project

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

func NewProject

func NewProject(path, sha string) (*Project, error)

func NewProjectFromRepo

func NewProjectFromRepo(repo *git.Repository, hash plumbing.Hash) (*Project, error)

NewProjectFromRepo builds a Project directly from an already-opened repository and a commit hash. Used in tests with in-memory repositories.

func (Project) BranchName

func (p Project) BranchName() (string, error)

func (Project) CommitDate

func (p Project) CommitDate() (time.Time, time.Time, error)

CommitDate returns the author and committer timestamps of the HEAD commit.

func (Project) CommitFiles

func (p Project) CommitFiles(c *object.Commit) ([]string, error)

CommitFiles returns the list of files changed in c relative to its first parent. For the initial commit (no parent), returns all files in the tree.

func (Project) CommitHash

func (p Project) CommitHash() (string, error)

func (Project) CommitHistory

func (p Project) CommitHistory() ([]CommitWithTags, error)

CommitHistory returns all commits reachable from HEAD in topological order (HEAD first, ancestors later), each annotated with the tag names pointing to it. Annotated tags are resolved to their target commit before matching. Tags whose commits cannot be resolved (e.g. shallow clone) are silently skipped.

func (Project) CommitSinceTag

func (p Project) CommitSinceTag(tag string) ([]*object.Commit, bool, error)

CommitSinceTag returns all commits reachable from HEAD back to (and including) the tagged commit. The bool truncated is true when the tag commit was not found during traversal — this happens in shallow clones where the tag is beyond the clone depth. In that case the returned commits are those that were traversable.

func (Project) CreateTag

func (p Project) CreateTag(name, message string) error

CreateTag creates an annotated tag on HEAD with the given message. Returns an error if the tag already exists.

func (Project) IsHeadTagged

func (p Project) IsHeadTagged(tag string) (bool, error)

IsHeadTagged reports whether the HEAD commit is the same commit pointed to by tag.

func (Project) IsShallow

func (p Project) IsShallow() bool

IsShallow reports whether this repository is a shallow clone. A shallow clone has one or more grafted commits (commits whose parents were artificially cut by git clone --depth=N).

func (Project) LastTag

func (p Project) LastTag(f format.VersionFormat) (string, error)

LastTag walks all reachable tags from HEAD, filters by f.IsValid, and returns the topologically closest ancestor tag. Returns "0.0.0" when no valid tag is found.

func (Project) PushTags

func (p Project) PushTags() error

PushTags pushes all local tags to the "origin" remote. Uses SSH agent for authentication; falls back to nil auth for HTTPS remotes whose credentials are managed by the OS credential store.

Jump to

Keyboard shortcuts

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