Skip to content

Fail clearly when git metadata is read-only#83

Draft
anmarchenko wants to merge 1 commit into
mainfrom
anmarchenko/git-metadata-writable-check
Draft

Fail clearly when git metadata is read-only#83
anmarchenko wants to merge 1 commit into
mainfrom
anmarchenko/git-metadata-writable-check

Conversation

@anmarchenko

Copy link
Copy Markdown
Member

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 .git directory 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 reports git metadata directory is not writable. Restore write access, rerun ddtest plan, and confirm the git preflight succeeds.

@anmarchenko anmarchenko marked this pull request as ready for review June 12, 2026 14:10
@anmarchenko anmarchenko requested a review from a team as a code owner June 12, 2026 14:10

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread internal/git/git.go
}

func getGitDirectory() (string, error) {
out, err := RunGitOutputFunc("rev-parse", "--absolute-git-dir")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@anmarchenko anmarchenko marked this pull request as draft June 12, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant