Documentation
¶
Overview ¶
Package git is icebath's own runs of git: environments that never prompt, page, open an editor, run hooks or filter drivers, or read the user's config beyond the directories it says are safe. The checkout a folder lies in. And the upkeep of a clone many processes share: what a killed git leaves behind, and maintenance one process at a time claims
Index ¶
- Constants
- func BranchName(name string) bool
- func CommonDir(ctx context.Context, dir string, env map[string]string) string
- func Configure(env map[string]string, settings ...[2]string)
- func Env(ctx context.Context, base map[string]string) map[string]string
- func Installed(env map[string]string) bool
- func Lines(text string) []string
- func Maintain(ctx context.Context, repo string, base map[string]string)
- func MarkPromisor(repo string) int
- func Output(ctx context.Context, dir string, env map[string]string, timeout time.Duration, ...) (string, bool)
- func Remembering(ctx context.Context) context.Context
- func RepoEnv(ctx context.Context, base map[string]string, dir string) map[string]string
- func Root(ctx context.Context, dir string, env map[string]string) string
- func Running() bool
- func SweepObjectLocks(gitDir string) []string
- func SweepTemp(repo string, age time.Duration) []string
- type Result
- func Capped(ctx context.Context, dir string, env map[string]string, timeout time.Duration, ...) (*Result, bool, error)
- func Fetch(ctx context.Context, dir string, timeout time.Duration, address string, ...) (*Result, error)
- func Run(ctx context.Context, dir string, env map[string]string, timeout time.Duration, ...) (*Result, error)
- type TimeoutError
Constants ¶
const StaleAge = 10 * time.Minute
Age past which a lock or a temp file git writes is taken as left by a git that died: a healthy fetch is done in minutes
Variables ¶
This section is empty.
Functions ¶
func BranchName ¶
Whether git takes the name for a branch, by the rules of git check-ref-format --branch: no part that starts with a dot or ends with .lock, no two dots in a row, no space, control character or any of ~^:?*[\, no @{, not @ or HEAD alone, not starting with a dash or ending with a dot, and no slash at either end or two in a row
func CommonDir ¶
Folder holding the objects of the checkout the folder lies in, as git in the environment finds it, the one a worktree or submodule .git file leads to. Empty outside one
func Env ¶
Environment of a git run that never prompts or runs the user's hooks, pager or editor: base, such as the profile's or a session's, otherwise this machine's variables alone, with git's config replaced by the overrides and the user's safe directories
func Installed ¶
Whether git is on the search path of the environment, this machine's when nil, otherwise on this process's, which a run then finds it on
func Maintain ¶
Keeps a clone many processes share fast, with git run in the environment base, such as the profile's: a background repack once its packs sprawl, and a fresh commit graph, each claimed by one process per interval. Every failure logged, none returned
func MarkPromisor ¶
Gives every pack of a partial clone without a promisor marker one, so git fetches the objects it lacks rather than failing. How many were marked
func Output ¶
func Output(ctx context.Context, dir string, env map[string]string, timeout time.Duration, args ...string) (string, bool)
Trimmed output of a run of git in the folder with the environment that succeeded, false for any failure
func Remembering ¶
Context under which Env and RepoEnv ask git for the user's safe directories, and for the filter drivers of each repository, once for all the work done under it, such as the reads of one request: a change of git's config meanwhile reaches the next request rather than this one. A context that remembers already is given back as it is
func RepoEnv ¶
Environment of a git run in one repository from base, as Env makes it, that also turns off every filter driver its config names, following its included files. nil when what it includes cannot be followed with certainty. Each call is given a map of its own
func Root ¶
Top of the checkout the folder lies in, as git in the environment finds it, in the form of this system. Empty outside one
func Running ¶
func Running() bool
Whether any git may be running on this machine, true whenever the look cannot tell
func SweepObjectLocks ¶
Removes the stale index locks of the object store under a git folder while no git runs. The paths removed
Types ¶
type Result ¶
What one run of git gave: its exit status and its output, invalid text replaced
func Capped ¶
func Capped(ctx context.Context, dir string, env map[string]string, timeout time.Duration, most int, args ...string) (*Result, bool, error)
Runs git as Run does with no input, its output read up to the bytes given: a run that writes more is stopped with every process it started, its result holding what came before, and cut says so. An error when it could not start or timed out first
func Fetch ¶
func Fetch(ctx context.Context, dir string, timeout time.Duration, address string, base map[string]string, lookup func(name string) string, args ...string) (*Result, error)
Runs a network verb of git in the environment base, such as a clone in the profile's, anonymously first, then with each credential the user has for the address's host while the remote keeps asking for one: a GitHub token of the environment lookup reads, the gh command's account, then what the credential helpers keep. A non zero exit is a Result, as Run's is
func Run ¶
func Run(ctx context.Context, dir string, env map[string]string, timeout time.Duration, input []byte, args ...string) (*Result, error)
Runs git in the folder with the environment, such as the profile's or a session's, this machine's variables alone when nil, input on its stdin, stopped with every process it started once the timeout passes. An error when it could not start or timed out, a non zero exit being a Result
type TimeoutError ¶
Run of git stopped once it outlasted its time
func (*TimeoutError) Error ¶
func (e *TimeoutError) Error() string