Documentation
¶
Overview ¶
Package gitx wraps the system git binary, so Skillcrew reuses the developer's existing credentials (credential helpers, SSH agent, gh).
Index ¶
- Variables
- func IsObjectID(s string) bool
- func NormalizeURL(s string) string
- func Redact(s string) string
- type Entry
- type ExportTree
- type Pin
- type RejectedError
- type Repo
- func (r *Repo) Blob(ctx context.Context, oid string) ([]byte, error)
- func (r *Repo) Branch(ctx context.Context, name string) (string, error)
- func (r *Repo) Commit(ctx context.Context, sha string) (string, error)
- func (r *Repo) DefaultBranch(ctx context.Context) (string, error)
- func (r *Repo) Export(ctx context.Context, treeish, dest string) error
- func (r *Repo) ExportTrees(ctx context.Context, trees []ExportTree) []error
- func (r *Repo) Fetch(ctx context.Context, branch string) error
- func (r *Repo) FetchTags(ctx context.Context, verify bool, tags ...string) error
- func (r *Repo) Git(ctx context.Context, args ...string) (string, error)
- func (r *Repo) NeutralizeAttributes() error
- func (r *Repo) RemoteURL(ctx context.Context) (string, error)
- func (r *Repo) ResolvePins(ctx context.Context, pins []Pin) []Target
- func (r *Repo) Tag(ctx context.Context, name string) (string, error)
- func (r *Repo) Tree(ctx context.Context, commit string) (map[string]Entry, error)
- type Target
Constants ¶
This section is empty.
Variables ¶
var ( ExportMaxBytes int64 = 256 << 20 ExportMaxFiles = 20000 )
Limits on what Export writes, so a hostile registry cannot fill the disk.
Functions ¶
func IsObjectID ¶
IsObjectID reports whether s is a full object id (commit, tree…).
func NormalizeURL ¶
NormalizeURL turns the "host/owner/repo" shorthand into an HTTPS clone URL. URLs, scp-like addresses and explicit local paths (absolute, ./ or ../) are returned unchanged: a shorthand never silently becomes a directory.
Types ¶
type ExportTree ¶
ExportTree is a tree to export into Dest: the directory Dir of Commit, whose tree id must be OID. Without a commit, the tree OID is listed directly.
type Pin ¶
type Pin struct {
Tag string // tag name, without refs/tags/
SHA string // full commit id, when Tag is empty
Dir string // slash-separated, relative to the root
}
Pin is a directory of the registry at a pinned tag or commit.
type RejectedError ¶
type RejectedError struct{ Reason string }
RejectedError is an export failure that would happen again with the same tree: too many files or bytes, or paths this filesystem cannot hold apart.
func (*RejectedError) Error ¶
func (e *RejectedError) Error() string
type Repo ¶
type Repo struct {
Dir string
}
Repo is a bare clone of a remote repository. It only holds what Skillcrew asked for: the followed branch under refs/remotes/origin and the pinned tags. Wildcard refspecs are never used: on case-insensitive filesystems a pushed "Main" branch or "V1" tag would overwrite "main" or "v1".
func (*Repo) Commit ¶
Commit checks that a full commit id exists. Abbreviated ids and ref names are rejected, so a branch can never stand in for a pinned commit.
func (*Repo) DefaultBranch ¶
DefaultBranch returns the remote's default branch.
func (*Repo) Export ¶
Export writes the files of a commit or tree id into dest, straight from git objects: no .gitattributes rule, filter driver, ident or eol conversion applies, so what is written is exactly what was reviewed. Symbolic links and submodules are skipped. Two paths that name the same file on this filesystem (case or Unicode normalization) fail the export.
func (*Repo) ExportTrees ¶
func (r *Repo) ExportTrees(ctx context.Context, trees []ExportTree) []error
ExportTrees exports trees like Export, with one listing per commit and a single object stream for all of them. Trees over the limits are rejected from their listing, before any content is read. It returns the error of each tree.
func (*Repo) FetchTags ¶
FetchTags fetches the given tags that are missing locally. Tags are immutable here: a tag known locally keeps its first commit and is never fetched again, so once every tag is known no network round trip is made. With verify, known tags are also compared with the remote, and those moved upstream are reported as an error (they still keep their first commit).
func (*Repo) NeutralizeAttributes ¶
NeutralizeAttributes overrides every in-tree .gitattributes rule that runs commands or rewrites content, for commands that check files out (propose).
func (*Repo) ResolvePins ¶
ResolvePins resolves pins to their commit and the tree of their directory with at most two git commands, whatever their number. Tags are matched by exact name, never by git's "did you mean" rules, and commits must be full ids, as with Tag and Commit.