Documentation
¶
Overview ¶
Package git runs the official git binary, and is the only thing in gitd that does.
Every process gets an environment built here rather than gitd's own: inheriting it once made a private repository look public, because the editor's `GIT_ASKPASS` answered for it. Killing a call kills git's whole process group (a job object on Windows), because git starts children of its own that would otherwise outlive it.
Index ¶
- Constants
- func About(err error, repository string) error
- func Redacted(address string) string
- type Cmd
- type ConfigEntry
- type Failure
- type Reason
- type Runner
- func (runner *Runner) Branch(ctx context.Context, dir string) (string, bool)
- func (runner *Runner) Config(ctx context.Context, path, key string) (string, error)
- func (runner *Runner) ConfigEntries(ctx context.Context, path string) ([]ConfigEntry, error)
- func (runner *Runner) HTTPBackend(root string, settings []string) *cgi.Handler
- func (runner *Runner) Resolve(ctx context.Context, dir, revision string) (string, bool, error)
- func (runner *Runner) ResolveObject(ctx context.Context, dir, revision string) (string, bool, error)
- func (runner *Runner) Run(ctx context.Context, command Cmd) (string, error)
- func (runner *Runner) Running() int64
- func (runner *Runner) SetConfig(ctx context.Context, dir string, keysAndValues ...string) error
- func (runner *Runner) Version(ctx context.Context) (string, error)
Constants ¶
const ( AuthRequired = gitdv1.GitFailure_REASON_AUTH_REQUIRED AuthRefused = gitdv1.GitFailure_REASON_AUTH_REFUSED NotFound = gitdv1.GitFailure_REASON_NOT_FOUND BadAddress = gitdv1.GitFailure_REASON_BAD_ADDRESS PathRefused = gitdv1.GitFailure_REASON_PATH_REFUSED Busy = gitdv1.GitFailure_REASON_BUSY Timeout = gitdv1.GitFailure_REASON_TIMEOUT Corrupt = gitdv1.GitFailure_REASON_CORRUPT Failed = gitdv1.GitFailure_REASON_GIT_FAILED NothingNew = gitdv1.GitFailure_REASON_NOTHING_NEW BranchRefused = gitdv1.GitFailure_REASON_BRANCH_REFUSED ConfigRefused = gitdv1.GitFailure_REASON_CONFIG_REFUSED PolicyRefused = gitdv1.GitFailure_REASON_POLICY_REFUSED Unsupported = gitdv1.GitFailure_REASON_UNSUPPORTED LimitReached = gitdv1.GitFailure_REASON_LIMIT_REACHED BranchExists = gitdv1.GitFailure_REASON_BRANCH_EXISTS Conflict = gitdv1.GitFailure_REASON_CONFLICT )
Variables ¶
This section is empty.
Functions ¶
func Redacted ¶
Redacted is an address fit to log and to answer with: a user and password written in it, as `https://user:token@host/…`, are left out.
Types ¶
type Cmd ¶
type Cmd struct {
Dir string
Args []string
Env []string
Local bool
Progress progress.Report
Differences bool
Input string
}
Cmd is one git invocation. Args starts with the subcommand; Env is added to the closed environment, as a request's credentials are; Local lets git read a repository on this disk, which only a pool is.
Differences says that git ending with status 1 found differences — as diff and merge-tree do — and answered, rather than failed. Input, when set, is what git reads on its standard input.
type ConfigEntry ¶
type ConfigEntry struct {
Key, Value string
}
ConfigEntry is one key of a git configuration file and its value. Key is as git lists it: section and name lowercased, a subsection as written.
type Failure ¶
Failure is an operation that did not go through: why, what git said about it, and the repository it was about. ExitCode is git's, or -1 when git never said.
func (*Failure) AboutAccess ¶
AboutAccess is whether another credential could change the answer.
func (*Failure) AccessRefused ¶
AccessRefused is what a failure about access means once it is known whether a credential was offered: asked for one when one was offered means that one was refused.
func (*Failure) Proto ¶
func (failure *Failure) Proto() *gitdv1.GitFailure
Proto is the failure as it travels in an error's detail.
type Reason ¶
type Reason = gitdv1.GitFailure_Reason
Reason is why an operation failed, as the contract names it.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner starts git processes.
func (*Runner) Branch ¶
Branch is the branch the repository at dir is on, and false when it is on none.
func (*Runner) Config ¶
Config reads one key from the git config file at path, and "" when it is not set.
func (*Runner) ConfigEntries ¶
ConfigEntries lists every key of the configuration file at path, without following its includes. Listing runs nothing the file names.
func (*Runner) HTTPBackend ¶
HTTPBackend is git's own smart HTTP server, `git http-backend`, over the repositories under root, run as gitd runs every git: its closed environment, no hooks and no global configuration. settings are `name=value` pairs set on its command line, where nothing in a repository can turn them back: which services it offers and their limits. The caller decides who may reach it and which repository; this only answers.
func (*Runner) Resolve ¶
Resolve returns the commit a revision names in the repository at dir, and false when there is none. The revision comes from outside, so it goes after `--end-of-options`.
func (*Runner) ResolveObject ¶
func (runner *Runner) ResolveObject(ctx context.Context, dir, revision string) (string, bool, error)
ResolveObject is the object a revision names in the repository at dir — a blob as `<commit>:<path>` — and false when it names none.