gitx

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gitx wraps the system git binary, so Skillcrew reuses the developer's existing credentials (credential helpers, SSH agent, gh).

Index

Constants

This section is empty.

Variables

View Source
var (
	ExportMaxBytes int64 = 256 << 20
	ExportMaxFiles       = 20000
)

Limits on what Export writes, so a hostile registry cannot fill the disk.

Functions

func IsObjectID

func IsObjectID(s string) bool

IsObjectID reports whether s is a full object id (commit, tree…).

func NormalizeURL

func NormalizeURL(s string) string

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.

func Redact

func Redact(s string) string

Redact hides credentials embedded in URLs.

Types

type Entry

type Entry struct {
	OID string
	Dir bool
}

Entry is an object of a commit's tree.

type ExportTree

type ExportTree struct {
	Commit, Dir, OID string
	Dest             string
}

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 Clone

func Clone(ctx context.Context, url, dir string) (*Repo, error)

Clone makes a bare clone of url into dir holding the remote's default branch.

func Open

func Open(dir string) *Repo

Open returns the repository stored in dir.

func (*Repo) Blob

func (r *Repo) Blob(ctx context.Context, oid string) ([]byte, error)

Blob returns the content of a blob.

func (*Repo) Branch

func (r *Repo) Branch(ctx context.Context, name string) (string, error)

Branch returns the commit a remote branch points to.

func (*Repo) Commit

func (r *Repo) Commit(ctx context.Context, sha string) (string, error)

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

func (r *Repo) DefaultBranch(ctx context.Context) (string, error)

DefaultBranch returns the remote's default branch.

func (*Repo) Export

func (r *Repo) Export(ctx context.Context, treeish, dest string) error

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) Fetch

func (r *Repo) Fetch(ctx context.Context, branch string) error

Fetch updates one remote branch.

func (*Repo) FetchTags

func (r *Repo) FetchTags(ctx context.Context, verify bool, tags ...string) error

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) Git

func (r *Repo) Git(ctx context.Context, args ...string) (string, error)

Git runs a git command in the repository and returns its trimmed output.

func (*Repo) NeutralizeAttributes

func (r *Repo) NeutralizeAttributes() error

NeutralizeAttributes overrides every in-tree .gitattributes rule that runs commands or rewrites content, for commands that check files out (propose).

func (*Repo) RemoteURL

func (r *Repo) RemoteURL(ctx context.Context) (string, error)

RemoteURL returns the URL of origin.

func (*Repo) ResolvePins

func (r *Repo) ResolvePins(ctx context.Context, pins []Pin) []Target

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.

func (*Repo) Tag

func (r *Repo) Tag(ctx context.Context, name string) (string, error)

Tag returns the commit a tag points to.

func (*Repo) Tree

func (r *Repo) Tree(ctx context.Context, commit string) (map[string]Entry, error)

Tree lists every file and directory of a commit, keyed by slash-separated path.

type Target

type Target struct {
	Commit, Tree string
	Err          error
}

Target is what a pin resolves to.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL