pluralsh / plural-cli

cli for the plural platform
MIT License
27 stars 10 forks source link

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

Closed maciejp-ro closed 1 year ago

maciejp-ro commented 1 year ago

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