When working in a git worktree rather than a full clone, plural build fails:
$ plural --debug build --only console
ERROR: 2023/10/03 14:11:38 validation.go:196: reference not found
2023/10/03 14:11:38 Failed to get git information: Could not compare current workspace to origin. Do you have an `origin` remote configured, or does your repo not have an initial commit?
I managed to track it down to gogit.Repository.Head() function: it seems to try to directly access objects in .git/. In worktree, .git is a file with reference to a parent repository, so there's no .git/HEAD.
This change uses actual git CLI instead of an incomplete reimplementation to get HEAD SHA and branch name. This makes Plural CLI work in a git worktree.
Some unrelated unit tests are failing, haven't touched these.
Labels
Test Plan
Checklist
[ ] If required, I have updated the Plural documentation accordingly.
[ ] I have added tests to cover my changes.
[ ] I have added a meaningful title and summary to convey the impact of this PR to a user.
[ ] I have added relevant labels to this PR to help with categorization for release notes.
Summary
When working in a
git worktree
rather than a full clone,plural build
fails:I managed to track it down to
gogit.Repository.Head()
function: it seems to try to directly access objects in.git/
. In worktree,.git
is a file with reference to a parent repository, so there's no.git/HEAD
.This change uses actual
git
CLI instead of an incomplete reimplementation to get HEAD SHA and branch name. This makes Plural CLI work in agit worktree
.Some unrelated unit tests are failing, haven't touched these.
Labels
Test Plan
Checklist