Documentation
¶
Overview ¶
Package gitx starts the git commands Djinn runs, each with a deadline: a git that talks to a remote (over ssh, a stalled connection or a prompt nobody sees) or waits on a lock never holds Djinn for good (W504).
Index ¶
- Variables
- func Command(ctx context.Context, dir string, args ...string) (cmd *exec.Cmd, cancel context.CancelFunc)
- func FetchBranch(ctx context.Context, dir, remote, branch string) (string, error)
- func OnCut(ctx context.Context, cut func(what, dir string)) context.Context
- func Uncut(ctx context.Context) (kept context.Context, done context.CancelFunc)
Constants ¶
This section is empty.
Variables ¶
var ( // Local is the longest a git command that stays in the repository may run: a merge or a checkout of a large one. Local = 10 * time.Minute // Network is the longest a git command that reaches a remote may run: fetch, push, ls-remote. Network = 5 * time.Minute // WaitDelay is how long a git stopped at its deadline or at its context's end has to end on SIGTERM, and then, once // killed, may keep its output open: an ssh it started may hold it. WaitDelay = 5 * time.Second // Finish is how long a git that changes a repository may run on once Djinn stops (Uncut), so that the stop leaves no // half a move; with WaitDelay, it stays well within the 30 s djinn up gives itself to stop. Finish = 15 * time.Second )
Functions ¶
func Command ¶
func Command(ctx context.Context, dir string, args ...string) (cmd *exec.Cmd, cancel context.CancelFunc)
Command is git with args, run in dir, never prompting for credentials, stopped at the earlier of ctx's end and its own deadline: Network for a command that reaches a remote, Local otherwise. Stopped, git gets SIGTERM, which lets it take its locks away (index.lock), and SIGKILL only WaitDelay later: killed first, it left them, and every later git in that worktree failed (W52). Call cancel once it has run: it logs it.
func FetchBranch ¶ added in v0.1.2
FetchBranch fetches branch from remote into its remote-tracking ref, refs/remotes/<remote>/<branch>, with the person's own credentials: what the remote holds of it now. It returns that commit; "" when the remote has no such branch, its remote-tracking ref then left as it was; an error when the remote did not answer.
func OnCut ¶ added in v0.2.0
OnCut returns ctx telling cut of each git a cancel of ctx stops before it ends: what it ran, "git reset", and the folder it ran in. A git that meets its deadline is not told.
func Uncut ¶ added in v0.2.0
Uncut is ctx without its cancel, for a git that changes a repository, or steps that must not stop half way (a merge and its abort, a branch moved and the checkout that follows it, or put back): a stop lets them end, for Finish at most past ctx's end, after which git is stopped as at a cancel, for ctx's cause. A deadline of ctx still holds, and so do its values. Call done once they ran.
Types ¶
This section is empty.