Documentation
¶
Index ¶
- Constants
- func AttachGitCommandWorker(r *git.Repository)
- func AttachRefreshExecutor(r *git.Repository)
- func AttachStateEvaluator(r *git.Repository)
- func Config(r *git.Repository, o *ConfigOptions) (value string, err error)
- func DiffStatRefs(r *git.Repository, ref1, ref2 string) (string, error)
- func EvaluateRepositoryState(r *git.Repository, outcome OperationOutcome)
- func Fetch(r *git.Repository, o *FetchOptions) (message string, err error)
- func FetchWithContext(ctx context.Context, r *git.Repository, o *FetchOptions) (message string, err error)
- func Merge(r *git.Repository, options *MergeOptions) (string, error)
- func MergeWithContext(ctx context.Context, r *git.Repository, options *MergeOptions) (string, error)
- func Pull(r *git.Repository, o *PullOptions) (string, error)
- func PullWithContext(ctx context.Context, r *git.Repository, o *PullOptions) (string, error)
- func Push(r *git.Repository, options *PushOptions) (string, error)
- func PushWithContext(ctx context.Context, r *git.Repository, options *PushOptions) (string, error)
- func Run(d string, c string, args []string) (string, error)
- func RunWithContext(ctx context.Context, d string, c string, args []string) (string, error)
- func RunWithContextTimeout(ctx context.Context, d string, c string, args []string, timeout time.Duration) (string, error)
- func RunWithTimeout(d string, c string, args []string, timeout time.Duration) (string, error)
- func ScheduleGitCommand(repo *git.Repository, request *GitCommandRequest) error
- func ScheduleRepositoryRefresh(r *git.Repository, outcome *OperationOutcome) error
- func ScheduleStateEvaluation(r *git.Repository, outcome OperationOutcome)
- type ConfigOptions
- type ConfigSite
- type FetchOptions
- type GitCommandFunc
- type GitCommandRequest
- type MergeOptions
- type OperationOutcome
- type OperationType
- type PullOptions
- type PushOptions
- type ResetType
Constants ¶
const DefaultFetchTimeout = 60 * time.Second
const DefaultGitCommandTimeout = 10 * time.Second
Variables ¶
This section is empty.
Functions ¶
func AttachGitCommandWorker ¶ added in v0.9.2
func AttachGitCommandWorker(r *git.Repository)
AttachGitCommandWorker registers the git queue listener responsible for executing scheduled git commands and forwarding their outcomes to the state queue.
func AttachRefreshExecutor ¶ added in v0.9.2
func AttachRefreshExecutor(r *git.Repository)
AttachRefreshExecutor registers the listener responsible for executing refresh requests on the TUI queue.
func AttachStateEvaluator ¶ added in v0.9.2
func AttachStateEvaluator(r *git.Repository)
AttachStateEvaluator wires repository events to the state evaluator.
func Config ¶
func Config(r *git.Repository, o *ConfigOptions) (value string, err error)
Config adds or reads config of a repository
func DiffStatRefs ¶
func DiffStatRefs(r *git.Repository, ref1, ref2 string) (string, error)
DiffStatRefs shows diff stat of two refs "git diff a1b2c3..e4f5g6 --stat"
func EvaluateRepositoryState ¶ added in v0.9.2
func EvaluateRepositoryState(r *git.Repository, outcome OperationOutcome)
EvaluateRepositoryState centralises repository state transitions after an operation. It is invoked after auto-fetch, queued jobs, and lazygit refreshes to ensure consistent clean/disabled and error handling across the application.
func Fetch ¶
func Fetch(r *git.Repository, o *FetchOptions) (message string, err error)
Fetch branches refs from one or more other repositories, along with the objects necessary to complete their histories.
func FetchWithContext ¶ added in v0.9.2
func FetchWithContext(ctx context.Context, r *git.Repository, o *FetchOptions) (message string, err error)
FetchWithContext performs fetch honouring the supplied context for cancellation and deadlines.
func Merge ¶
func Merge(r *git.Repository, options *MergeOptions) (string, error)
Merge incorporates changes from the named commits or branches into the current branch
func MergeWithContext ¶ added in v0.9.2
func MergeWithContext(ctx context.Context, r *git.Repository, options *MergeOptions) (string, error)
MergeWithContext executes merge honouring the provided context for cancellation and deadlines.
func Pull ¶
func Pull(r *git.Repository, o *PullOptions) (string, error)
Pull incorporates changes from a remote repository into the current branch.
func PullWithContext ¶ added in v0.9.2
func PullWithContext(ctx context.Context, r *git.Repository, o *PullOptions) (string, error)
PullWithContext performs pull respecting context cancellation and deadlines.
func Push ¶ added in v0.9.0
func Push(r *git.Repository, options *PushOptions) (string, error)
func PushWithContext ¶ added in v0.9.2
func PushWithContext(ctx context.Context, r *git.Repository, options *PushOptions) (string, error)
PushWithContext runs git push and respects context cancellation and deadlines.
func Run ¶
Run runs the OS command and return its output. If the output returns error it also encapsulates it as a golang.error which is a return code of the command except zero
func RunWithContext ¶ added in v0.9.2
RunWithContext executes a command honouring the provided context for cancellation.
func RunWithContextTimeout ¶ added in v0.9.2
func RunWithTimeout ¶
RunWithTimeout runs a command with a timeout context to prevent hanging
func ScheduleGitCommand ¶ added in v0.9.2
func ScheduleGitCommand(repo *git.Repository, request *GitCommandRequest) error
ScheduleGitCommand publishes a request to the repository git queue.
func ScheduleRepositoryRefresh ¶ added in v0.9.2
func ScheduleRepositoryRefresh(r *git.Repository, outcome *OperationOutcome) error
ScheduleRepositoryRefresh emits an event-driven request to refresh repository metadata. When outcome is non-nil, it will be forwarded to the refresh listener so the resulting state evaluation can apply the provided context after the refresh completes.
func ScheduleStateEvaluation ¶ added in v0.9.2
func ScheduleStateEvaluation(r *git.Repository, outcome OperationOutcome)
ScheduleStateEvaluation emits an event-driven request to recompute repository state.
Types ¶
type ConfigOptions ¶
type ConfigOptions struct {
// Section
Section string
// Option
Option string
// Site should be Global or Local
Site ConfigSite
}
ConfigOptions defines the rules for commit operation
type ConfigSite ¶
type ConfigSite string
ConfigSite defines a string type for the site.
const ( // ConfigSiteLocal defines a local config. ConfigSiteLocal ConfigSite = "local" // ConfigSiteGlobal defines a global config. ConfigSiteGlobal ConfigSite = "global" )
type FetchOptions ¶
type FetchOptions struct {
// Name of the remote to fetch from. Defaults to origin.
RemoteName string
// Credentials holds the user and password information
Credentials *git.Credentials
// Before fetching, remove any remote-tracking references that no longer
// exist on the remote.
Prune bool
// Show what would be done, without making any changes.
DryRun bool
// Process logs the output to stdout
Progress bool
// Force allows the fetch to update a local branch even when the remote
// branch does not descend from it.
Force bool
// Timeout is the maximum duration allowed for the fetch command when
// executed via the legacy git CLI. If zero, a sensible default is used.
Timeout time.Duration
}
FetchOptions defines the rules for fetch operation
type GitCommandFunc ¶ added in v0.9.2
type GitCommandFunc func(ctx context.Context) OperationOutcome
GitCommandFunc describes the work executed on the git queue. The returned OperationOutcome will be forwarded to the state queue regardless of success or failure.
type GitCommandRequest ¶ added in v0.9.2
type GitCommandRequest struct {
Key string
Timeout time.Duration
Operation OperationType
Execute GitCommandFunc
}
GitCommandRequest encapsulates metadata required by the git queue listener. It declares a timeout enforced by the queue infrastructure.
type MergeOptions ¶
type MergeOptions struct {
// Name of the branch to merge with.
BranchName string
// Be verbose.
Verbose bool
// With true do not show a diffstat at the end of the merge.
NoStat bool
}
MergeOptions defines the rules of a merge operation
type OperationOutcome ¶ added in v0.9.2
type OperationOutcome struct {
Operation OperationType
Err error
Message string
SuppressSuccess bool
}
OperationOutcome captures the result of an operation for state evaluation.
type OperationType ¶ added in v0.9.2
type OperationType string
OperationType identifies the job or action that updated a repository.
const ( OperationFetch OperationType = "fetch" OperationPull OperationType = "pull" OperationMerge OperationType = "merge" OperationRebase OperationType = "rebase" OperationPush OperationType = "push" OperationRefresh OperationType = "refresh" OperationGit OperationType = "git" OperationStateProbe OperationType = "state-probe" )
type PullOptions ¶
type PullOptions struct {
// Name of the remote to fetch from. Defaults to origin.
RemoteName string
// ReferenceName Remote branch to clone. If empty, uses HEAD.
ReferenceName string
// Fetch only ReferenceName if true.
SingleBranch bool
// Credentials holds the user and password information
Credentials *git.Credentials
// Process logs the output to stdout
Progress bool
// Force allows the pull to update a local branch even when the remote
// branch does not descend from it.
Force bool
// FFOnly ensures only fast-forward merges are allowed.
FFOnly bool
// Rebase performs the pull using rebase instead of merge.
Rebase bool
}
PullOptions defines the rules for pull operation
type PushOptions ¶ added in v0.9.0
type PushOptions struct {
// Name of the remote to push to. Defaults to origin.
RemoteName string
// ReferenceName identifies the ref to push. Defaults to the current branch name.
ReferenceName string
// Force toggles --force pushes when required.
Force bool
}
PushOptions defines the rules of the push operation
type ResetType ¶
type ResetType string
ResetType defines a string type for reset git command.
const ( // ResetHard Resets the index and working tree. Any changes to tracked // files in the working tree since <commit> are discarded. ResetHard ResetType = "hard" // ResetMixed Resets the index but not the working tree (i.e., the changed // files are preserved but not marked for commit) and reports what has not // been updated. This is the default action. ResetMixed ResetType = "mixed" // ResetMerge Resets the index and updates the files in the working tree // that are different between <commit> and HEAD, but keeps those which are // different between the index and working tree ResetMerge ResetType = "merge" // ResetSoft Does not touch the index file or the working tree at all // (but resets the head to <commit> ResetSoft ResetType = "soft" // ResetKeep Resets index entries and updates files in the working tree // that are different between <commit> and HEAD ResetKeep ResetType = "keep" )