Pre-flight checks
Current behavior
When running lrc hooks install --local or lrc hooks uninstall --local from a nested subdirectory of a Git repository, the CLI exits with:
Error: not in a git repository (no .git directory found)
Developers must be at the repository root containing .git to manage hooks locally, which breaks the expected workflow when working in subdirectories.
Expected behavior
git-lrc should detect the enclosing Git repository when invoked from any subdirectory. lrc hooks install --local and lrc hooks uninstall --local should succeed when run from any path inside a Git worktree.
Steps to reproduce
-
Build and install: make build-local && lrc hooks install
-
Create a subdirectory: mkdir -p subdir && cd subdir
-
Try local install: lrc hooks install --local
-
Observe:
Error: not in a git repository (no .git directory found)
Environment
- lrc version: Dev / main
- OS: Linux
- Shell: bash
- Git version: any
Additional context
Root cause
The function IsGitRepositoryCurrentDir() in gitops/config.go checks for .git using os.Stat(".git"), which only looks at the current working directory. When invoked from a subdirectory, .git is not found even though the directory is inside a valid Git worktree.
Naming bug
The name says "check current dir for .git" but the actual purpose is "check whether we are inside any Git repository." Per project convention (AGENTS.md): names must match function meaning.
Proposed fix
Replace os.Stat(".git") with git rev-parse --is-inside-work-tree, rename IsGitRepositoryCurrentDir → IsGitRepository, and drop the unused "os" import.
Pre-flight checks
Current behavior
When running
lrc hooks install --localorlrc hooks uninstall --localfrom a nested subdirectory of a Git repository, the CLI exits with:Developers must be at the repository root containing
.gitto manage hooks locally, which breaks the expected workflow when working in subdirectories.Expected behavior
git-lrcshould detect the enclosing Git repository when invoked from any subdirectory.lrc hooks install --localandlrc hooks uninstall --localshould succeed when run from any path inside a Git worktree.Steps to reproduce
Build and install:
make build-local && lrc hooks installCreate a subdirectory:
mkdir -p subdir && cd subdirTry local install:
lrc hooks install --localObserve:
Environment
Additional context
Root cause
The function
IsGitRepositoryCurrentDir()ingitops/config.gochecks for.gitusingos.Stat(".git"), which only looks at the current working directory. When invoked from a subdirectory,.gitis not found even though the directory is inside a valid Git worktree.Naming bug
The name says "check current dir for .git" but the actual purpose is "check whether we are inside any Git repository." Per project convention (AGENTS.md): names must match function meaning.
Proposed fix
Replace
os.Stat(".git")withgit rev-parse --is-inside-work-tree, renameIsGitRepositoryCurrentDir→IsGitRepository, and drop the unused"os"import.