Documentation
¶
Index ¶
- Variables
- type Client
- func (c *Client) CloneAtTag(ctx context.Context, repoURL, tag, destDir string) error
- func (c *Client) CloneRepository(ctx context.Context, repoURL string) (*git.Repository, error)
- func (c *Client) FilterTags(tags []string, pattern string) []string
- func (c *Client) FilterTagsWithPrefix(tags []string, prefix string) []string
- func (c *Client) GetCommitFromClone(ctx context.Context, repoURL, commitSHA string) (*object.Commit, error)
- func (c *Client) GetCommitInfo(ctx context.Context, repoURL, commitSHA string) (*CommitInfo, error)
- func (c *Client) GetCommitSHAForTag(ctx context.Context, repoURL, tag string) (string, error)
- func (c *Client) GetDefaultBranch(ctx context.Context, repoURL string) (string, error)
- func (c *Client) GetFirstValidTag(ctx context.Context, repoURL string, filter types.VersionFilterFunc) (string, error)
- func (c *Client) GetLatestTag(ctx context.Context, repoURL string) (string, error)
- func (c *Client) GetLatestTagWithFilter(ctx context.Context, repoURL, filter string) (string, error)
- func (c *Client) GetTagInfo(ctx context.Context, repoURL, tagName string) (*TagInfo, error)
- func (c *Client) GetTags(ctx context.Context, repoURL string) ([]string, error)
- func (c *Client) GetTagsWithFilter(ctx context.Context, repoURL, filterPrefix, filterContains string) ([]string, error)
- func (c *Client) HeadCommit(dir string) (string, error)
- func (c *Client) ListBranches(ctx context.Context, repoURL string) ([]string, error)
- func (c *Client) VerifyCommitExists(ctx context.Context, repoURL, commitSHA string) (bool, error)
- type CommitInfo
- type FileCommitInfo
- type Repository
- type TagInfo
Constants ¶
This section is empty.
Variables ¶
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.
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 (*Client) CloneAtTag ¶ added in v0.3.0
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) CloneRepository ¶
CloneRepository clones a repository to memory for more advanced operations
func (*Client) FilterTags ¶
FilterTags filters tags based on a pattern
func (*Client) FilterTagsWithPrefix ¶
FilterTagsWithPrefix filters tags that start with a specific prefix
func (*Client) GetCommitFromClone ¶
func (c *Client) GetCommitFromClone(ctx context.Context, repoURL, commitSHA string) (*object.Commit, error)
GetCommitFromClone gets detailed commit information by cloning the repository
func (*Client) GetCommitInfo ¶
GetCommitInfo gets information about a commit
func (*Client) GetCommitSHAForTag ¶
GetCommitSHAForTag gets the commit SHA for a specific tag
func (*Client) GetDefaultBranch ¶
GetDefaultBranch gets the default branch of the repository
func (*Client) GetFirstValidTag ¶
func (c *Client) GetFirstValidTag(ctx context.Context, repoURL string, filter types.VersionFilterFunc) (string, error)
GetFirstValidTag finds the first tag that passes all filtering criteria
func (*Client) GetLatestTag ¶
GetLatestTag returns the latest tag from a Git repository
func (*Client) GetLatestTagWithFilter ¶
func (c *Client) GetLatestTagWithFilter(ctx context.Context, repoURL, filter string) (string, error)
GetLatestTagWithFilter returns the latest tag that matches the filter
func (*Client) GetTagInfo ¶
GetTagInfo gets detailed information about a tag
func (*Client) GetTagsWithFilter ¶
func (c *Client) GetTagsWithFilter(ctx context.Context, repoURL, filterPrefix, filterContains string) ([]string, error)
GetTagsWithFilter returns filtered tags from a Git repository with early termination
func (*Client) HeadCommit ¶ added in v0.3.0
HeadCommit returns the commit SHA the checkout at dir points to.
func (*Client) ListBranches ¶
ListBranches lists all branches in the repository
type CommitInfo ¶
CommitInfo represents information about a Git commit
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(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 ¶
Repository represents a Git repository