git

package
v1.7.13 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2025 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 CommitComparisonResult added in v1.1.0

type CommitComparisonResult int
const (
	UnknownCommitComparisonResult CommitComparisonResult = -2
	AIsAncestorOfB                CommitComparisonResult = -1
	CommitsEqual                  CommitComparisonResult = 0
	BIsAncestorOfA                CommitComparisonResult = 1
	CommitsDiverged               CommitComparisonResult = 2
)

type GitRepository added in v1.1.0

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

GitRepository implements the Repository interface

func New

func New(cfg *config.Config, opts ...Option) *GitRepository

func (*GitRepository) Fetch added in v1.1.0

func (r *GitRepository) Fetch(ctx context.Context) error

func (*GitRepository) GetCurrentBranch added in v1.1.0

func (r *GitRepository) GetCurrentBranch(ctx context.Context) (string, error)

GetCurrentBranch returns the name of the current branch

func (*GitRepository) GetLatestCommit added in v1.1.0

func (r *GitRepository) GetLatestCommit(ctx context.Context) (string, error)

func (*GitRepository) GetRemoteCommit added in v1.1.0

func (r *GitRepository) GetRemoteCommit(ctx context.Context) (string, error)

func (*GitRepository) HandleCommitComparison added in v1.1.0

func (repo *GitRepository) HandleCommitComparison(ctx context.Context, localCommit, remoteCommit string) (CommitComparisonResult, error)

HandleCommitComparison handles the commit comparison and decides whether to pull changes

func (*GitRepository) IsAncestor added in v1.1.0

func (r *GitRepository) IsAncestor(ctx context.Context, commitA, commitB string) (bool, error)

IsAncestor checks if commitA is an ancestor of commitB

func (*GitRepository) IsClean added in v1.1.0

func (r *GitRepository) IsClean(ctx context.Context) (bool, error)

IsClean returns true if the working directory is clean (no uncommitted changes)

func (*GitRepository) Pull added in v1.1.0

func (r *GitRepository) Pull(ctx context.Context) (string, error)

type Option added in v1.1.0

type Option func(*GitRepository)

Option configures a GitRepository

func WithExecutor added in v1.1.0

func WithExecutor(exec executor.CommandExecutor) Option

WithExecutor sets a custom executor

type Repository

type Repository interface {
	GetLatestCommit(ctx context.Context) (string, error)
	GetRemoteCommit(ctx context.Context) (string, error)
	Fetch(ctx context.Context) error
	Pull(ctx context.Context) (string, error)
	GetCurrentBranch(ctx context.Context) (string, error)
	IsClean(ctx context.Context) (bool, error)
	HandleCommitComparison(ctx context.Context, localCommit, remoteCommit string) (CommitComparisonResult, error)
}

Repository defines the interface for git operations

Jump to

Keyboard shortcuts

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