MCPcopy Index your code
hub / github.com/docker/docker-agent / repoRoot

Function repoRoot

pkg/worktree/worktree.go:338–348  ·  view source on GitHub ↗

repoRoot returns the worktree root of the git repository containing dir, or [ErrNotGitRepository] when dir is not inside one.

(ctx context.Context, dir string)

Source from the content-addressed store, hash-verified

336// repoRoot returns the worktree root of the git repository containing dir,
337// or [ErrNotGitRepository] when dir is not inside one.
338func repoRoot(ctx context.Context, dir string) (string, error) {
339 out, err := gitOutput(ctx, dir, "rev-parse", "--show-toplevel")
340 if err != nil {
341 var exitErr *exec.ExitError
342 if errors.As(err, &exitErr) {
343 return "", ErrNotGitRepository
344 }
345 return "", err
346 }
347 return filepath.Clean(out), nil
348}
349
350// fetchBase updates the local copy of a remote-tracking base ref (e.g.
351// "origin/main") so the worktree branches from the latest remote state. Refs

Callers 2

CreateFunction · 0.85
CreatePRFunction · 0.85

Calls 1

gitOutputFunction · 0.70

Tested by

no test coverage detected