git

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotInRepository = errors.New("path is not inside a git repository")

ErrNotInRepository indicates that a file path does not reside inside a (discoverable) git repository.

View Source
var ErrUntracked = errors.New("file has no commit history in repository")

ErrUntracked indicates that a file exists on disk and inside a git repository, but has no commit history for that path.

Functions

This section is empty.

Types

type Client

type Client struct{}

Client represents a Git client using go-git

func New

func New() *Client

New creates a new Git client

func (*Client) CloneAtTag added in v0.3.0

func (c *Client) CloneAtTag(ctx context.Context, repoURL, tag, destDir string) error

CloneAtTag clones the repository at the given tag into destDir. It first attempts a shallow single-branch clone (cheap); some servers reject shallow tag fetches, in which case it falls back to a full clone of the tag ref.

func (*Client) GetCommitSHAForTag

func (c *Client) GetCommitSHAForTag(ctx context.Context, repoURL, tag string) (string, error)

GetCommitSHAForTag gets the commit SHA for a specific tag

func (*Client) HeadCommit added in v0.3.0

func (c *Client) HeadCommit(_ context.Context, dir string) (string, error)

HeadCommit returns the commit SHA the checkout at dir points to. ctx is accepted for interface consistency with the client's other methods; the underlying go-git read is local-disk-only and doesn't support cancellation.

func (*Client) ListTags added in v0.6.0

func (c *Client) ListTags(ctx context.Context, repoURL string) ([]string, error)

ListTags returns the names of all tags in the remote repository, in no particular order; callers pick the newest by comparing parsed versions.

type FileCommitInfo added in v0.3.0

type FileCommitInfo struct {
	// Time is the committer time of the last commit that touched the file.
	Time time.Time
	// Hash is the last commit's SHA (hex).
	Hash string
	// Shallow reports whether the containing repository has truncated
	// (shallow) history.
	Shallow bool
	// Dirty reports whether the on-disk content differs from the file's
	// blob at HEAD.
	Dirty bool
}

FileCommitInfo describes the last commit that touched a file, plus working-tree state relevant to a "how stale is this checkout" heuristic.

func LastCommitInfo added in v0.3.0

func LastCommitInfo(ctx context.Context, filePath string) (*FileCommitInfo, error)

LastCommitInfo locates the git repository containing filePath and returns information about the last commit that touched it, along with whether the on-disk content is dirty relative to HEAD and whether the repository has shallow history.

It returns ErrNotInRepository if filePath is not inside a discoverable git repository, and ErrUntracked if the file has no commit history.

type Repository

type Repository struct {
	URL    string
	Branch string
}

Repository represents a Git repository

Jump to

Keyboard shortcuts

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