Help us shape the future of Go! Take the 2026 Go Developer Survey

gitroot

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package gitroot derives a directory's enclosing git repository root via the external git binary. Missing repo, missing dir, and missing git binary all return ok=false with no error distinction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RepoRoot

func RepoRoot(dir string) (root string, ok bool)

RepoRoot returns the cleaned, symlink-resolved absolute path of the git repository containing dir. Canonicalisation matches CLI path hand-off so gitstate keys and registry roots agree on macOS (/var vs /private/var) and other symlink-spelled temp roots. ok is false — never an error — when dir is outside any repo, does not exist, or git is not on PATH.

func RepoRootForNew

func RepoRootForNew(dir string) (root string, ok bool)

RepoRootForNew derives the git root a not-yet-created dir would belong to by walking up to the nearest existing ancestor. Same uniform (root, ok) contract as RepoRoot.

Types

This section is empty.

Jump to

Keyboard shortcuts

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