fix(trunk): anchor git-diff-check at the workspace root - #198
Merged
Conversation
git-diff-check invoked `git diff --check ${target}` from Trunk's
sandbox copy of the target. This repository is consumed as a submodule, so
its `.git` is a file whose gitdir is relative to the superproject. The
sandbox copy invalidates that relative path and every run failed with:
fatal: not a git repository: (null)
Anchor the command at ${workspace} so repository discovery resolves against
the real checkout instead of the sandbox directory.
Verified: `trunk check --no-fix --ci --filter=git-diff-check` reports
"No issues" where it previously exited 128.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
git-diff-checkfailed on every run in this repository with:Trunk copies lint targets into a sandbox directory (
/tmp/trunk-<uid>/…) and runs the linter from there. This repository is consumed as a submodule of the Z-Shell meta-workspace, so its.gitis a file containing a gitdir path relative to the superproject:That relative path does not resolve from the sandbox, so
git diff --checkcould not find a repository and exited 128 on every target.Fix
Anchor the command at the real workspace so repository discovery resolves against the actual checkout:
This is the override documented for relative-gitdir checkouts; the upstream plugin definition is otherwise unchanged.
Scope
The same failure affected 9 repositories in the workspace. Sibling PRs carry the identical change.
z-shell/zsh-lintwas checked and deliberately not patched — its gitdir is absolute, so it was never affected.Test plan
trunk check --no-fix --ci --filter=git-diff-check <file>returns✔ No issues(previously exit 128)trunk check --no-fix --ci <file>reports nonot a git repositoryerrors and no missing binariestrunk.yamlparses with exactly onelint.definitionskey and onegit-diff-checkentry (guards against a duplicate-key merge that would silently drop other custom linter definitions)Note for reviewers
CI runners clone normally, so
.gitis a real directory there and this check was already passing in CI. The bug only reproduces in a submodule/worktree checkout — which is how the meta-workspace consumes this repo. The override is a no-op for the CI case.