Fail clearly when git metadata is read-only#83
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 31bc927386
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| func getGitDirectory() (string, error) { | ||
| out, err := RunGitOutputFunc("rev-parse", "--absolute-git-dir") |
There was a problem hiding this comment.
Check the common Git directory for worktrees
In a linked worktree, git rev-parse --absolute-git-dir returns the per-worktree admin directory (for example .git/worktrees/<name>), while Git documents --git-common-dir as the common repository metadata location and the TIA fetch paths later write repository objects/shallow state during git fetch (civisibility/utils/git.go:330 and :450). If the common .git directory is read-only but this per-worktree directory is writable, this preflight passes and ddtest still fails later without the clear startup error this change is adding; check the absolute common git dir as well/instead. Git docs: https://git-scm.com/docs/git-rev-parse/2.13.7.html#Documentation/git-rev-parse.txt---git-common-dir
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
this is interesting to know, but for CI worktree is more like an edge case for CI environments that we target - but we'll keep it mind, worktrees get more usage with AI agents
What
Fail during ddtest startup when the Git metadata directory is not writable, with a clear error explaining that ddtest needs write access to fetch repository metadata for Test Impact Analysis.
Why
Some customer environments expose the
.gitdirectory as read-only. ddtest later needs writable Git metadata for repository operations used by Test Impact Analysis, so the old behavior could fail unclearly after initialization had already started. This preflight keeps the failure early and actionable.E2E testing
In a Git checkout, make the Git metadata directory read-only and run
ddtest plan. Confirm ddtest exits before Datadog initialization and reportsgit metadata directory is not writable. Restore write access, rerunddtest plan, and confirm the git preflight succeeds.