Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use git rev-parse instead of gogit.Repository.Head() to find out head branch & sha #461

Merged
merged 1 commit into from
Oct 4, 2023

Conversation

maciejp-ro
Copy link
Contributor

@maciejp-ro maciejp-ro commented Oct 3, 2023

Summary

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.

@maciejp-ro maciejp-ro force-pushed the shell-out-for-git-head branch from de07e0a to e2eedca Compare October 3, 2023 14:31
Copy link
Member

@michaeljguarino michaeljguarino left a comment

Choose a reason for hiding this comment

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

This looks should work, we actually used rev-parse prior and I think i flipped it to leverage a typed api. If it breaks some workflows though, should definitely revert.

@michaeljguarino michaeljguarino merged commit 78727e1 into pluralsh:main Oct 4, 2023
3 of 11 checks passed
michaeljguarino pushed a commit that referenced this pull request Aug 28, 2024
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.

2 participants