git

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package git provides git operations for ReleasePilot.

Package git provides git operations for ReleasePilot.

Package git provides git operations for ReleasePilot.

Package git provides git operations for ReleasePilot.

Index

Constants

View Source
const (
	CommitTypeFeat     = changes.CommitTypeFeat
	CommitTypeFix      = changes.CommitTypeFix
	CommitTypeDocs     = changes.CommitTypeDocs
	CommitTypeStyle    = changes.CommitTypeStyle
	CommitTypeRefactor = changes.CommitTypeRefactor
	CommitTypePerf     = changes.CommitTypePerf
	CommitTypeTest     = changes.CommitTypeTest
	CommitTypeBuild    = changes.CommitTypeBuild
	CommitTypeCI       = changes.CommitTypeCI
	CommitTypeChore    = changes.CommitTypeChore
	CommitTypeRevert   = changes.CommitTypeRevert
	// CommitTypeUnknown represents an unknown commit type.
	CommitTypeUnknown CommitType = ""
)

CommitType constants - aliases to domain layer constants.

View Source
const (
	ReleaseTypeMajor = changes.ReleaseTypeMajor
	ReleaseTypeMinor = changes.ReleaseTypeMinor
	ReleaseTypePatch = changes.ReleaseTypePatch
	ReleaseTypeNone  = changes.ReleaseTypeNone
)

ReleaseType constants - aliases to domain layer constants.

Variables

View Source
var (
	// ConventionalCommitRegex matches the conventional commit format.
	// Format: <type>(<scope>)!?: <description>
	ConventionalCommitRegex = regexp.MustCompile(
		`^(?P<type>feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)` +
			`(?:\((?P<scope>[^)]+)\))?` +
			`(?P<breaking>!)?` +
			`:\s*` +
			`(?P<description>.+)$`,
	)

	// BreakingChangeRegex matches BREAKING CHANGE footer.
	BreakingChangeRegex = regexp.MustCompile(`(?i)^BREAKING[ -]CHANGE:\s*(.+)$`)

	// ReferenceRegex matches issue/PR references.
	// Matches: #123, GH-123, fixes #123, closes #123, etc.
	ReferenceRegex = regexp.MustCompile(`(?i)(?:(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s+)?(?:#|GH-)(\d+)`)
)

Regular expressions for parsing conventional commits.

View Source
var ErrInvalidGitRef = errors.New("invalid git reference")

ErrInvalidGitRef is returned when a git reference contains invalid characters.

Functions

func CommitTypeDisplayName

func CommitTypeDisplayName(t CommitType) string

CommitTypeDisplayName returns a human-readable name for a commit type.

func CommitTypeEmoji

func CommitTypeEmoji(t CommitType) string

CommitTypeEmoji returns an emoji for a commit type.

func FormatConventionalCommit

func FormatConventionalCommit(cc *ConventionalCommit) string

FormatConventionalCommit formats a conventional commit as a string.

func IsMajorTrigger

func IsMajorTrigger(t CommitType) bool

IsMajorTrigger returns true if this commit type can trigger a major bump (with breaking change). Deprecated: Use changes.ReleaseTypeFromCommitType() instead.

func IsVersionBump

func IsVersionBump(t CommitType) bool

IsVersionBump returns true if this commit type should trigger a version bump. Deprecated: Use changes.CommitType.AffectsChangelog() or domain logic instead.

func MustValidateGitRef

func MustValidateGitRef(ref string) string

MustValidateGitRef validates a git reference and panics if invalid. Use this only in contexts where invalid refs indicate a programming error.

func Priority

func Priority(r ReleaseType) int

Priority returns the priority of the release type (higher = more significant). Deprecated: Use changes.MaxReleaseType() for comparing release types.

func ValidateGitRef

func ValidateGitRef(ref string) error

ValidateGitRef validates that a git reference is safe to use in shell commands. It returns an error if the reference contains potentially dangerous characters that could be used for command injection.

Valid references include: - Branch names: main, feature/my-branch, release-1.0 - Tag names: v1.0.0, release/v2.0 - Commit SHAs: abc1234, full 40-char SHA - Relative refs: HEAD, HEAD~1, HEAD^2, main~5 - Remote refs: origin/main, upstream/feature

Types

type Author

type Author struct {
	// Name is the author's name.
	Name string `json:"name"`
	// Email is the author's email.
	Email string `json:"email"`
}

Author represents a git author or committer.

type Branch

type Branch struct {
	// Name is the branch name.
	Name string `json:"name"`
	// Hash is the commit hash the branch points to.
	Hash string `json:"hash"`
	// IsRemote indicates if this is a remote branch.
	IsRemote bool `json:"is_remote"`
	// Remote is the remote name (for remote branches).
	Remote string `json:"remote,omitempty"`
	// Upstream is the upstream branch name.
	Upstream string `json:"upstream,omitempty"`
}

Branch represents a git branch.

type CategorizedChanges

type CategorizedChanges struct {
	// Features contains feat commits.
	Features []ConventionalCommit `json:"features,omitempty"`
	// Fixes contains fix commits.
	Fixes []ConventionalCommit `json:"fixes,omitempty"`
	// Performance contains perf commits.
	Performance []ConventionalCommit `json:"performance,omitempty"`
	// Documentation contains docs commits.
	Documentation []ConventionalCommit `json:"documentation,omitempty"`
	// Refactoring contains refactor commits.
	Refactoring []ConventionalCommit `json:"refactoring,omitempty"`
	// Breaking contains breaking change commits.
	Breaking []ConventionalCommit `json:"breaking,omitempty"`
	// Other contains all other commits.
	Other []ConventionalCommit `json:"other,omitempty"`
	// All contains all commits in order.
	All []ConventionalCommit `json:"all"`
}

CategorizedChanges groups commits by their type for changelog generation.

func CategorizeCommits

func CategorizeCommits(commits []ConventionalCommit) *CategorizedChanges

CategorizeCommits groups commits by their type.

func (*CategorizedChanges) DetermineReleaseType

func (c *CategorizedChanges) DetermineReleaseType() ReleaseType

DetermineReleaseType determines the release type based on the changes.

func (*CategorizedChanges) HasBreakingChanges

func (c *CategorizedChanges) HasBreakingChanges() bool

HasBreakingChanges returns true if there are any breaking changes.

func (*CategorizedChanges) HasChanges

func (c *CategorizedChanges) HasChanges() bool

HasChanges returns true if there are any categorized changes.

func (*CategorizedChanges) TotalCount

func (c *CategorizedChanges) TotalCount() int

TotalCount returns the total number of commits.

type Commit

type Commit struct {
	// Hash is the commit SHA.
	Hash string `json:"hash"`
	// ShortHash is the abbreviated commit SHA (7 characters).
	ShortHash string `json:"short_hash"`
	// Message is the full commit message.
	Message string `json:"message"`
	// Subject is the first line of the commit message.
	Subject string `json:"subject"`
	// Body is the commit message body (everything after the first line).
	Body string `json:"body"`
	// Author is the commit author.
	Author Author `json:"author"`
	// Committer is the person who made the commit.
	Committer Author `json:"committer"`
	// Date is the commit date.
	Date time.Time `json:"date"`
	// Parents are the parent commit hashes.
	Parents []string `json:"parents"`
}

Commit represents a git commit.

type CommitFilter

type CommitFilter struct {
	// Types filters commits by type.
	Types []CommitType
	// Authors filters commits by author email.
	Authors []string
	// ExcludeAuthors excludes commits by author email.
	ExcludeAuthors []string
	// Scopes filters commits by scope.
	Scopes []string
	// ExcludeScopes excludes commits by scope.
	ExcludeScopes []string
	// IncludeNonConventional includes non-conventional commits.
	IncludeNonConventional bool
	// OnlyBreaking only includes breaking changes.
	OnlyBreaking bool
	// Since filters commits after this date.
	Since *time.Time
	// Until filters commits before this date.
	Until *time.Time
	// PathFilter filters commits that touch these paths.
	PathFilter []string
}

CommitFilter defines criteria for filtering commits.

type CommitOptions

type CommitOptions struct {
	// Message is the commit message.
	Message string
	// Author is the commit author.
	Author *Author
	// AllowEmpty allows creating an empty commit.
	AllowEmpty bool
	// Sign signs the commit with GPG.
	Sign bool
	// Amend amends the previous commit.
	Amend bool
}

CommitOptions configures commit creation.

type CommitType

type CommitType = changes.CommitType

CommitType is an alias to the domain CommitType for backward compatibility. New code should prefer using changes.CommitType directly.

type ConventionalCommit

type ConventionalCommit struct {
	// Commit is the underlying git commit.
	Commit Commit `json:"commit"`
	// Type is the commit type (feat, fix, etc.).
	Type CommitType `json:"type"`
	// Scope is the optional scope of the commit.
	Scope string `json:"scope,omitempty"`
	// Description is the commit description (after type and scope).
	Description string `json:"description"`
	// Body is the commit body.
	Body string `json:"body,omitempty"`
	// Footer is the commit footer (contains breaking change info, references, etc.).
	Footer string `json:"footer,omitempty"`
	// Breaking indicates if this is a breaking change.
	Breaking bool `json:"breaking"`
	// BreakingDescription is the description of the breaking change.
	BreakingDescription string `json:"breaking_description,omitempty"`
	// References are issue/PR references found in the commit.
	References []Reference `json:"references,omitempty"`
	// IsConventional indicates if the commit follows conventional commit format.
	IsConventional bool `json:"is_conventional"`
}

ConventionalCommit represents a parsed conventional commit.

func FilterCommits

func FilterCommits(commits []ConventionalCommit, filter CommitFilter) []ConventionalCommit

FilterCommits filters commits based on criteria. Uses pre-compiled maps for O(1) lookups instead of O(n) linear searches.

func ParseConventionalCommit

func ParseConventionalCommit(message string) (*ConventionalCommit, error)

ParseConventionalCommit parses a commit message as a conventional commit.

func ParseConventionalCommitWithOptions

func ParseConventionalCommitWithOptions(commit Commit, opts ParseOptions) (*ConventionalCommit, error)

ParseConventionalCommitWithOptions parses a commit with options.

type DiffStats

type DiffStats struct {
	// FilesChanged is the number of files changed.
	FilesChanged int `json:"files_changed"`
	// Insertions is the number of lines inserted.
	Insertions int `json:"insertions"`
	// Deletions is the number of lines deleted.
	Deletions int `json:"deletions"`
	// Files is the list of changed files with their stats.
	Files []FileStats `json:"files,omitempty"`
}

DiffStats contains statistics about changes between two refs.

type FetchOptions

type FetchOptions struct {
	// Remote is the remote name (default: "origin").
	Remote string
	// Tags fetches all tags.
	Tags bool
	// Prune removes remote-tracking references that no longer exist.
	Prune bool
	// Depth limits the fetch depth (0 = full).
	Depth int
}

FetchOptions configures fetch operations.

func DefaultFetchOptions

func DefaultFetchOptions() FetchOptions

DefaultFetchOptions returns the default fetch options.

type FileStats

type FileStats struct {
	// Path is the file path.
	Path string `json:"path"`
	// Insertions is the number of lines inserted.
	Insertions int `json:"insertions"`
	// Deletions is the number of lines deleted.
	Deletions int `json:"deletions"`
	// Status is the file status (added, modified, deleted, renamed).
	Status string `json:"status"`
	// OldPath is the old path (for renamed files).
	OldPath string `json:"old_path,omitempty"`
}

FileStats contains statistics about changes to a single file.

type ParseOptions

type ParseOptions struct {
	// StrictMode requires commits to follow conventional commit format exactly.
	StrictMode bool
	// ParseReferences enables parsing of issue/PR references.
	ParseReferences bool
	// ParseCoAuthors enables parsing of co-author information.
	ParseCoAuthors bool
}

ParseOptions configures commit parsing behavior.

func DefaultParseOptions

func DefaultParseOptions() ParseOptions

DefaultParseOptions returns the default parsing options.

type PullOptions

type PullOptions struct {
	// Remote is the remote name (default: "origin").
	Remote string
	// Branch is the branch to pull (default: current branch).
	Branch string
	// Rebase uses rebase instead of merge.
	Rebase bool
	// Depth limits the fetch depth (0 = full).
	Depth int
}

PullOptions configures pull operations.

func DefaultPullOptions

func DefaultPullOptions() PullOptions

DefaultPullOptions returns the default pull options.

type PushOptions

type PushOptions struct {
	// Remote is the remote name (default: "origin").
	Remote string
	// Force enables force push.
	Force bool
	// Tags pushes tags.
	Tags bool
	// DryRun simulates the push.
	DryRun bool
	// RefSpec is the refspec to push.
	RefSpec string
}

PushOptions configures push operations.

func DefaultPushOptions

func DefaultPushOptions() PushOptions

DefaultPushOptions returns the default push options.

type Reference

type Reference struct {
	// Type is the reference type (e.g., "issue", "pr", "closes", "fixes").
	Type string `json:"type"`
	// ID is the reference ID (issue/PR number).
	ID string `json:"id"`
	// Raw is the raw reference string as found in the commit.
	Raw string `json:"raw"`
}

Reference represents a reference to an issue or PR.

type ReleaseType

type ReleaseType = changes.ReleaseType

ReleaseType is an alias to the domain ReleaseType for backward compatibility. New code should prefer using changes.ReleaseType directly.

func DetectReleaseType

func DetectReleaseType(commits []ConventionalCommit) ReleaseType

DetectReleaseType determines the release type based on conventional commits.

type RemoteInfo

type RemoteInfo struct {
	// Name is the remote name.
	Name string `json:"name"`
	// URL is the remote URL.
	URL string `json:"url"`
	// PushURL is the push URL (if different from fetch URL).
	PushURL string `json:"push_url,omitempty"`
}

RemoteInfo contains information about a git remote.

type RepositoryInfo

type RepositoryInfo struct {
	// Root is the repository root directory.
	Root string `json:"root"`
	// CurrentBranch is the current checked out branch.
	CurrentBranch string `json:"current_branch"`
	// DefaultBranch is the default branch (main/master).
	DefaultBranch string `json:"default_branch"`
	// Remotes is the list of configured remotes.
	Remotes []RemoteInfo `json:"remotes"`
	// IsDirty indicates if the working tree has uncommitted changes.
	IsDirty bool `json:"is_dirty"`
	// HeadCommit is the current HEAD commit hash.
	HeadCommit string `json:"head_commit"`
}

RepositoryInfo contains information about the git repository.

type Service

type Service interface {

	// GetRepositoryRoot returns the absolute path to the repository root.
	GetRepositoryRoot(ctx context.Context) (string, error)

	// GetRepositoryInfo returns information about the repository.
	GetRepositoryInfo(ctx context.Context) (*RepositoryInfo, error)

	// IsClean returns true if the working tree has no uncommitted changes.
	IsClean(ctx context.Context) (bool, error)

	// GetCommit returns a specific commit by hash.
	GetCommit(ctx context.Context, hash string) (*Commit, error)

	// GetCommitsSince returns all commits since the given reference.
	GetCommitsSince(ctx context.Context, ref string) ([]Commit, error)

	// GetCommitsBetween returns all commits between two references.
	GetCommitsBetween(ctx context.Context, from, to string) ([]Commit, error)

	// GetHeadCommit returns the current HEAD commit.
	GetHeadCommit(ctx context.Context) (*Commit, error)

	// GetBranchCommit returns the latest commit on a specific branch.
	GetBranchCommit(ctx context.Context, branch string) (*Commit, error)

	// GetLatestTag returns the most recent tag.
	GetLatestTag(ctx context.Context) (*Tag, error)

	// GetLatestVersionTag returns the most recent version tag matching the prefix.
	GetLatestVersionTag(ctx context.Context, prefix string) (*Tag, error)

	// ListTags returns all tags in the repository.
	ListTags(ctx context.Context) ([]Tag, error)

	// ListVersionTags returns all version tags matching the prefix.
	ListVersionTags(ctx context.Context, prefix string) ([]Tag, error)

	// GetTag returns a specific tag by name, or an error if not found.
	GetTag(ctx context.Context, name string) (*Tag, error)

	// CreateTag creates a new tag.
	CreateTag(ctx context.Context, name, message string, opts TagOptions) error

	// DeleteTag deletes a tag.
	DeleteTag(ctx context.Context, name string) error

	// PushTag pushes a tag to the remote.
	PushTag(ctx context.Context, name string, opts PushOptions) error

	// GetCurrentBranch returns the current branch name.
	GetCurrentBranch(ctx context.Context) (string, error)

	// GetDefaultBranch returns the default branch name (main/master).
	GetDefaultBranch(ctx context.Context) (string, error)

	// ListBranches returns all branches in the repository.
	ListBranches(ctx context.Context) ([]Branch, error)

	// GetRemoteURL returns the URL of the specified remote.
	GetRemoteURL(ctx context.Context, name string) (string, error)

	// Push pushes changes to the remote.
	Push(ctx context.Context, opts PushOptions) error

	// Pull pulls changes from the remote and merges them.
	Pull(ctx context.Context, opts PullOptions) error

	// Fetch fetches from the remote.
	Fetch(ctx context.Context, opts FetchOptions) error

	// GetDiffStats returns statistics about changes between two refs.
	GetDiffStats(ctx context.Context, from, to string) (*DiffStats, error)

	// ParseConventionalCommit parses a commit message as a conventional commit.
	ParseConventionalCommit(message string) (*ConventionalCommit, error)

	// ParseConventionalCommits parses multiple commits as conventional commits.
	ParseConventionalCommits(commits []Commit, opts ParseOptions) ([]ConventionalCommit, error)

	// DetectReleaseType determines the release type based on conventional commits.
	DetectReleaseType(commits []ConventionalCommit) ReleaseType

	// CategorizeCommits groups commits by their type.
	CategorizeCommits(commits []ConventionalCommit) *CategorizedChanges

	// FilterCommits filters commits based on criteria.
	FilterCommits(commits []ConventionalCommit, filter CommitFilter) []ConventionalCommit
}

Service defines the interface for git operations.

type ServiceConfig

type ServiceConfig struct {
	// RepoPath is the path to the repository.
	RepoPath string
	// DefaultRemote is the default remote name.
	DefaultRemote string
	// GPGSign enables GPG signing by default.
	GPGSign bool
	// GPGKeyID is the GPG key ID to use for signing.
	GPGKeyID string
	// UseCLIFallback enables falling back to git CLI when go-git fails.
	// This is useful for authentication with credential helpers.
	UseCLIFallback bool
	// AuthToken is an optional authentication token for HTTPS push.
	// When set, this is used instead of relying on credential helpers.
	AuthToken string
	// AuthUsername is the username for token auth (default: "git" for GitHub).
	AuthUsername string
}

ServiceConfig configures the git service.

func DefaultServiceConfig

func DefaultServiceConfig() ServiceConfig

DefaultServiceConfig returns the default service configuration.

type ServiceImpl

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

ServiceImpl is the go-git implementation of the git service.

func NewService

func NewService(opts ...ServiceOption) (*ServiceImpl, error)

NewService creates a new git service.

func (*ServiceImpl) CategorizeCommits

func (s *ServiceImpl) CategorizeCommits(commits []ConventionalCommit) *CategorizedChanges

CategorizeCommits groups commits by their type.

func (*ServiceImpl) CreateTag

func (s *ServiceImpl) CreateTag(_ context.Context, name, message string, opts TagOptions) error

CreateTag creates a new tag.

func (*ServiceImpl) DeleteTag

func (s *ServiceImpl) DeleteTag(_ context.Context, name string) error

DeleteTag deletes a tag.

func (*ServiceImpl) DetectReleaseType

func (s *ServiceImpl) DetectReleaseType(commits []ConventionalCommit) ReleaseType

DetectReleaseType determines the release type based on conventional commits.

func (*ServiceImpl) Fetch

func (s *ServiceImpl) Fetch(_ context.Context, opts FetchOptions) error

Fetch fetches from the remote.

func (*ServiceImpl) FilterCommits

func (s *ServiceImpl) FilterCommits(commits []ConventionalCommit, filter CommitFilter) []ConventionalCommit

FilterCommits filters commits based on criteria.

func (*ServiceImpl) GetBranchCommit

func (s *ServiceImpl) GetBranchCommit(_ context.Context, branch string) (*Commit, error)

GetBranchCommit returns the latest commit on a specific branch.

func (*ServiceImpl) GetCommit

func (s *ServiceImpl) GetCommit(_ context.Context, hash string) (*Commit, error)

GetCommit returns a specific commit by hash.

func (*ServiceImpl) GetCommitsBetween

func (s *ServiceImpl) GetCommitsBetween(ctx context.Context, from, to string) ([]Commit, error)

GetCommitsBetween returns all commits between two references.

func (*ServiceImpl) GetCommitsSince

func (s *ServiceImpl) GetCommitsSince(ctx context.Context, ref string) ([]Commit, error)

GetCommitsSince returns all commits since the given reference.

func (*ServiceImpl) GetCurrentBranch

func (s *ServiceImpl) GetCurrentBranch(_ context.Context) (string, error)

GetCurrentBranch returns the current branch name.

func (*ServiceImpl) GetDefaultBranch

func (s *ServiceImpl) GetDefaultBranch(_ context.Context) (string, error)

GetDefaultBranch returns the default branch name (main/master).

func (*ServiceImpl) GetDiffStats

func (s *ServiceImpl) GetDiffStats(_ context.Context, from, to string) (*DiffStats, error)

GetDiffStats returns statistics about changes between two refs.

func (*ServiceImpl) GetHeadCommit

func (s *ServiceImpl) GetHeadCommit(_ context.Context) (*Commit, error)

GetHeadCommit returns the current HEAD commit.

func (*ServiceImpl) GetLatestTag

func (s *ServiceImpl) GetLatestTag(ctx context.Context) (*Tag, error)

GetLatestTag returns the most recent tag.

func (*ServiceImpl) GetLatestVersionTag

func (s *ServiceImpl) GetLatestVersionTag(ctx context.Context, prefix string) (*Tag, error)

GetLatestVersionTag returns the most recent version tag matching the prefix.

func (*ServiceImpl) GetRemoteURL

func (s *ServiceImpl) GetRemoteURL(_ context.Context, name string) (string, error)

GetRemoteURL returns the URL of the specified remote.

func (*ServiceImpl) GetRepositoryInfo

func (s *ServiceImpl) GetRepositoryInfo(ctx context.Context) (*RepositoryInfo, error)

GetRepositoryInfo returns information about the repository. Results are cached for repoInfoCacheTTL to avoid repeated syscalls during operations that query repository info multiple times.

func (*ServiceImpl) GetRepositoryRoot

func (s *ServiceImpl) GetRepositoryRoot(_ context.Context) (string, error)

GetRepositoryRoot returns the absolute path to the repository root.

func (*ServiceImpl) GetTag

func (s *ServiceImpl) GetTag(_ context.Context, name string) (*Tag, error)

GetTag returns a specific tag by name, or an error if not found.

func (*ServiceImpl) InvalidateRepoInfoCache

func (s *ServiceImpl) InvalidateRepoInfoCache()

InvalidateRepoInfoCache forces the repository info cache to be refreshed on the next GetRepositoryInfo call. Use after operations that modify repository state (e.g., creating tags, switching branches).

func (*ServiceImpl) IsClean

func (s *ServiceImpl) IsClean(ctx context.Context) (bool, error)

IsClean returns true if the working tree has no uncommitted changes.

func (*ServiceImpl) ListBranches

func (s *ServiceImpl) ListBranches(ctx context.Context) ([]Branch, error)

ListBranches returns all branches in the repository.

func (*ServiceImpl) ListTags

func (s *ServiceImpl) ListTags(ctx context.Context) ([]Tag, error)

ListTags returns all tags in the repository.

func (*ServiceImpl) ListVersionTags

func (s *ServiceImpl) ListVersionTags(ctx context.Context, prefix string) ([]Tag, error)

ListVersionTags returns all version tags matching the prefix.

func (*ServiceImpl) ParseConventionalCommit

func (s *ServiceImpl) ParseConventionalCommit(message string) (*ConventionalCommit, error)

ParseConventionalCommit parses a commit message as a conventional commit.

func (*ServiceImpl) ParseConventionalCommits

func (s *ServiceImpl) ParseConventionalCommits(commits []Commit, opts ParseOptions) ([]ConventionalCommit, error)

ParseConventionalCommits parses multiple commits as conventional commits.

func (*ServiceImpl) Pull

func (s *ServiceImpl) Pull(_ context.Context, opts PullOptions) error

Pull pulls changes from the remote and merges them.

func (*ServiceImpl) Push

func (s *ServiceImpl) Push(_ context.Context, opts PushOptions) error

Push pushes changes to the remote.

func (*ServiceImpl) PushTag

func (s *ServiceImpl) PushTag(ctx context.Context, name string, opts PushOptions) error

PushTag pushes a tag to the remote.

type ServiceOption

type ServiceOption func(*ServiceConfig)

ServiceOption configures the git service.

func WithAuthToken added in v0.2.1

func WithAuthToken(token string) ServiceOption

WithAuthToken sets the authentication token for HTTPS push.

func WithAuthUsername added in v0.2.1

func WithAuthUsername(username string) ServiceOption

WithAuthUsername sets the username for token auth.

func WithCLIFallback added in v0.2.1

func WithCLIFallback(enabled bool) ServiceOption

WithCLIFallback sets whether to use CLI fallback.

func WithDefaultRemote

func WithDefaultRemote(remote string) ServiceOption

WithDefaultRemote sets the default remote.

func WithGPGSign

func WithGPGSign(keyID string) ServiceOption

WithGPGSign enables GPG signing.

func WithRepoPath

func WithRepoPath(path string) ServiceOption

WithRepoPath sets the repository path.

type Tag

type Tag struct {
	// Name is the tag name.
	Name string `json:"name"`
	// Hash is the commit hash the tag points to.
	Hash string `json:"hash"`
	// Message is the tag message (for annotated tags).
	Message string `json:"message,omitempty"`
	// Tagger is the person who created the tag (for annotated tags).
	Tagger *Author `json:"tagger,omitempty"`
	// Date is the tag date.
	Date time.Time `json:"date"`
	// IsAnnotated indicates if this is an annotated tag.
	IsAnnotated bool `json:"is_annotated"`
}

Tag represents a git tag.

type TagFilter

type TagFilter struct {
	// Prefix filters tags by prefix (e.g., "v").
	Prefix string
	// Pattern filters tags by glob pattern.
	Pattern string
	// Since filters tags after this date.
	Since *time.Time
	// Until filters tags before this date.
	Until *time.Time
}

TagFilter defines criteria for filtering tags.

type TagOptions

type TagOptions struct {
	// Annotated creates an annotated tag (vs lightweight).
	Annotated bool
	// Sign signs the tag with GPG.
	Sign bool
	// Force overwrites an existing tag.
	Force bool
	// Ref is the reference to tag (default: HEAD).
	Ref string
}

TagOptions configures tag creation.

func DefaultTagOptions

func DefaultTagOptions() TagOptions

DefaultTagOptions returns the default tag options.

Jump to

Keyboard shortcuts

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