Documentation
¶
Index ¶
- type CommitComparisonResult
- type GitRepository
- func (r *GitRepository) Fetch(ctx context.Context) error
- func (r *GitRepository) GetCurrentBranch(ctx context.Context) (string, error)
- func (r *GitRepository) GetLatestCommit(ctx context.Context) (string, error)
- func (r *GitRepository) GetRemoteCommit(ctx context.Context) (string, error)
- func (repo *GitRepository) HandleCommitComparison(ctx context.Context, localCommit, remoteCommit string) (CommitComparisonResult, error)
- func (r *GitRepository) IsAncestor(ctx context.Context, commitA, commitB string) (bool, error)
- func (r *GitRepository) IsClean(ctx context.Context) (bool, error)
- func (r *GitRepository) Pull(ctx context.Context) (string, error)
- type Option
- type Repository
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 (*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
IsAncestor checks if commitA is an ancestor of commitB
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
Click to show internal directories.
Click to hide internal directories.