gitutil

package
v0.20.5 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package gitutil shells out to the `git` CLI (docs/conventions.md: "Git/GitHub: never go-git") to answer the small set of questions the daemon needs about a launch directory: is it a git checkout, where is its top level, what branch is it on, is it a linked worktree, and (for the reader) which files does git see there. Nothing here is Claude-Code-format knowledge; it stays out of internal/claudecode by design.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Branch

func Branch(ctx context.Context, dir string) *string

Branch returns the current branch name, or nil when dir isn't a git checkout or is in a detached-HEAD state — the wire's own "null when not git" contract (docs/protocol.md's repo.branch).

func IsRepo

func IsRepo(ctx context.Context, dir string) bool

IsRepo reports whether dir is inside a git working tree.

func IsWorktree

func IsWorktree(ctx context.Context, dir string) bool

IsWorktree reports whether dir is a linked worktree: its git-dir and the repository's common-dir differ (kb:adr/launch-hybrid-mru-directory-memory's recognition rule).

func ListFiles added in v0.18.3

func ListFiles(ctx context.Context, dir string) ([]string, error)

ListFiles returns every path `git ls-files -co --exclude-standard` reports for dir (a checkout root) — tracked files plus untracked-but-not-ignored ones, one repo-relative, forward-slash path per entry, in git's own listing order. It answers only what git considers present; a caller that cares about a subset (internal/server's reader wants only the `.md` ones) filters the result itself, so this stays a plain listing rather than growing a second, caller-specific query — the one place that runs `git ls-files` at all, so a caller never carries its own git argv.

func TopLevel added in v0.19.4

func TopLevel(ctx context.Context, dir string) *string

TopLevel returns the root of the checkout containing dir, or nil when dir isn't inside one. The daemon compares it to tell two directories of one checkout from two checkouts (internal/session.Elsewhere); a linked worktree has its own top level.

Types

This section is empty.

Jump to

Keyboard shortcuts

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