gitcl: log output of failed git commands.
#409
Merged
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.
Hello, and thanks a bunch for this awesome crate!
This patch makes any
gitcommands in thevergen-gitclsubcrate log their stdout/stderr on failure to provide more background.Backstory:
I've just wasted a couple of hours debugging
vergentelling me that it was "not within a suitable 'git' worktree!" when it clearly was...The root cause of the issue turned out to be that the
rust-build.actionI was using had "dubious ownership" on the.gitdirectory, as it is a container-based GitHub action where the$GITHUB_WORKSPACEis bind-mounted within the container and thus has differing user IDs.The effect of this was that some
gitsubcommands (most notablyrev-parse) would error out like so:While
vergenwould only output :I have proposed a fix on the rust-build action's side but had
vergenjust exposed the stderr of thegit rev-parsecommand to me from the get-go, it would have saved me hours of debugging (reproducing the setup with a container-based GitHub action is tedious to say the least).Fix notes.
I've simply went with manually-formatted
eprintln!()statements in therun_cmd()method used throughout the rest of the code to log anygitcommand failures since I don't consider adding a whole logging crate tree necessary, but I could if it's deemed it is.