git

package
v0.14.4 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package git provides Git repository operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicAuth

type BasicAuth struct {
	Username string
	Password string
}

BasicAuth holds HTTPS authentication credentials

type Commit

type Commit struct {
	SHA      string // full commit SHA
	ShortSHA string // first 7 chars
	Author   string
	Date     time.Time
	Message  string
}

Commit represents a git commit

type Repository

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

Repository wraps a go-git repository

func NewFromRaw added in v0.14.4

func NewFromRaw(r *gogit.Repository) *Repository

NewFromRaw wraps a *gogit.Repository for use in tests. Not for production use.

func OpenRepo

func OpenRepo(path string) (*Repository, error)

OpenRepo opens a git repository at the given path. Returns ShallowRepoError if the repo is a shallow clone.

func (*Repository) CreateAnnotatedTag

func (r *Repository) CreateAnnotatedTag(name, message string) (*Tag, error)

CreateAnnotatedTag creates an annotated tag at HEAD. message: tag message (e.g., "chore(release): 1.0.0")

func (*Repository) FindLatestTag added in v0.14.4

func (r *Repository) FindLatestTag(tagPrefix string) (*Tag, error)

FindLatestTag finds the tag with the highest semver value across all tags (annotated and lightweight). If tagPrefix is non-empty, only tags with that prefix are considered. Tags whose names do not parse as valid semver after prefix stripping are silently skipped. Returns nil, nil when no parseable semver tags exist (bootstrap case).

func (*Repository) FindPreviousAnnotatedTag

func (r *Repository) FindPreviousAnnotatedTag(current *Tag) (*Tag, error)

FindPreviousAnnotatedTag finds the annotated tag before the given tag. Returns nil, nil if the given tag is the only tag.

func (*Repository) FindTagByName

func (r *Repository) FindTagByName(name string) (*Tag, error)

FindTagByName looks up a tag by name. Supports both annotated and lightweight tags. Returns (nil, nil) if the tag does not exist.

func (*Repository) ListCommitsBetweenTags

func (r *Repository) ListCommitsBetweenTags(from, to *Tag) ([]Commit, error)

ListCommitsBetweenTags lists commits between two tags (exclusive of from, inclusive of to). If from is nil, returns all commits from to back to the repository root (bootstrap case). Returns commits in reverse-chronological order.

func (*Repository) ListCommitsSinceRef

func (r *Repository) ListCommitsSinceRef(refName string) ([]Commit, error)

ListCommitsSinceRef lists commits reachable from HEAD but not from refName — equivalent to `git log refName..HEAD`. Used on pull_request events to lint only the PR's own commits (base ref → HEAD), excluding history already on the base branch (including commits reachable via merge-commit parents, as in GitHub's refs/pull/N/merge checkout). Returns commits in reverse-chronological order (newest first).

func (*Repository) ListCommitsSinceTag

func (r *Repository) ListCommitsSinceTag(tag *Tag) ([]Commit, error)

ListCommitsSinceTag lists all commits from HEAD back to (but not including) the tag's target commit. If tag is nil, returns all commits from HEAD (bootstrap case). Returns commits in reverse-chronological order (newest first).

func (*Repository) PushTag

func (r *Repository) PushTag(ctx context.Context, tagName string, auth BasicAuth) error

PushTag pushes a tag to the remote repository. auth: BasicAuth{Username, Password} for HTTPS authentication

type ShallowRepoError

type ShallowRepoError struct {
	Message string
}

ShallowRepoError is returned when a shallow clone is detected

func (ShallowRepoError) Error

func (e ShallowRepoError) Error() string

type Tag

type Tag struct {
	Name string // tag name (e.g., "v1.0.0")
	SHA  string // tag object SHA (annotated) or commit SHA (lightweight)

	IsAnnotated bool // true = annotated tag object; false = lightweight tag
	// contains filtered or unexported fields
}

Tag represents a git tag (annotated or lightweight).

func NewTag

func NewTag(name, sha, targetSHA string) *Tag

NewTag constructs a Tag with all fields set. Intended for use in tests.

func (*Tag) TargetSHA

func (t *Tag) TargetSHA() string

TargetSHA returns the commit SHA that this tag points to (distinct from tag object SHA)

Jump to

Keyboard shortcuts

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