Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotARepo = errors.New("not a git repository")
ErrNotARepo is WorkingDiff's answer for a directory with no git directory it may use: none at all, or one that resolves outside the root.
Functions ¶
func IsRepo ¶
IsRepo reports whether dir contains a .git entry, in any of its forms or as a symlink to one (os.Stat follows symlinks).
func WorkingDiff ¶ added in v0.12.0
func WorkingDiff(ctx context.Context, root *os.Root, name string, maxBytes int) (staged, unstaged string, err error)
WorkingDiff returns the staged and unstaged diff of the repository at name inside root, each cut to maxBytes. git gets descriptors opened through root as GIT_WORK_TREE, GIT_DIR and GIT_COMMON_DIR, which outrank core.worktree, so no swapped component, outside .git or core.worktree can point it elsewhere.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler implements git HTTP endpoints (non-AI operations).
func NewHandler ¶
NewHandler returns a Handler scoped to workDir. Shutdown ends the status scans it runs behind its answers.
func (*Handler) RegisterRoutes ¶
RegisterRoutes installs the /api/git/* mux entries.
func (*Handler) RepoRemotes ¶
func (h *Handler) RepoRemotes(ctx context.Context) []RepoRemote
RepoRemotes resolves every discovered workspace repo's `origin` remote.
Discovery reuses cachedDiscoverRepos, so this shares the singleflighted scan the git views already perform rather than walking the workspace again. The one subprocess per repo is `git remote get-url origin`, which reads config and touches no network.
type Option ¶
type Option func(*Handler)
Option configures a Handler at construction time.
func WithShowMax ¶ added in v0.13.0
WithShowMax caps the blob /api/git/show serves at n bytes; a larger revision answers 413. Non-positive keeps the default.
type RepoRemote ¶
type RepoRemote struct {
// Name is the workspace directory ("." for the workspace root itself), the
// name the git panel addresses the repository by.
Name string
// WebBase is the origin's scheme and authority when the remote is an http or
// https URL, and "" for an ssh or scp-like remote.
WebBase string
Slug string
}
RepoRemote is one workspace repo's origin in the coordinates a forge addresses it by: WebBase selects the forge connection, Slug is the owner/name path. A repo with no parseable origin is absent.
type ShowRefusal ¶ added in v0.13.0
type ShowRefusal struct {
Error string `json:"error"`
Code ShowRefusalCode `json:"code"`
}
ShowRefusal is a refused GET /api/git/show's body; it carries no content.
type ShowRefusalCode ¶ added in v0.13.0
type ShowRefusalCode string
ShowRefusalCode is the machine-readable reason on a ShowRefusal.
type ShowResponse ¶ added in v0.13.0
ShowResponse is GET /api/git/show's success reply. Absent marks a path the ref does not hold, whose Content is legitimately empty.