Open black7375 opened 1 year ago
Hi @black7375, thanks for reporting. I think this would be fairly straightforward to fix; I just haven't gotten around to it yet.
Relevant reading: https://stackoverflow.com/questions/28852902/how-to-detect-if-head-points-to-an-unborn-branch
Hey :wave:!
Kind of new to Rust, but I wouldn't mind helping out if you'd like? This should be a fix in the init.rs
file right? Please let me know :smile:
Hi @Parsifal-M, sorry for the late reply. This error message can occur without having run git branchless init
, and it probably shouldn't be an error to init
in a repo before having made the first commit.
The best thing to here could be to refactor the get_main_branch
function to write a message to stdout and return an ExitCode
, or to catch the raised error at a higher level by attempting to downcast it. These are probably straightforward but maybe not easy (for a Rust beginner). You can try anyways, if you like, and post in the Discord chat if you have trouble.
There are a couple of issues marked as "good first issue" which you could try instead; #494 is very similar. I'll remove the "good first issue" label from this one.
Description of the bug
After the initialization of the
git-branchless
, panic occurs without any commit.Expected behavior
Instead of panic, it is better to get a message that there is no commit.
Sample message:
Actual behavior
No response
Version of
rustc
rustc 1.67.0-nightly (01fbc5ae7 2022-12-07)
Automated bug report
Software version
git-branchless 0.6.0
Operating system
Linux 6.0.11-zen1-1-zen
Command-line
Environment variables
Git version
Hooks
Show 6 hooks
##### Hook `post-commit` ``` #!/bin/sh ## START BRANCHLESS CONFIG git branchless hook-post-commit "$@" ## END BRANCHLESS CONFIG ``` ##### Hook `post-merge` ``` #!/bin/sh ## START BRANCHLESS CONFIG git branchless hook-post-merge "$@" ## END BRANCHLESS CONFIG ``` ##### Hook `post-rewrite` ``` #!/bin/sh ## START BRANCHLESS CONFIG git branchless hook-post-rewrite "$@" ## END BRANCHLESS CONFIG ``` ##### Hook `post-checkout` ``` #!/bin/sh ## START BRANCHLESS CONFIG git branchless hook-post-checkout "$@" ## END BRANCHLESS CONFIG ``` ##### Hook `pre-auto-gc` ``` #!/bin/sh ## START BRANCHLESS CONFIG git branchless hook-pre-auto-gc "$@" ## END BRANCHLESS CONFIG ``` ##### Hook `reference-transaction` ``` #!/bin/sh ## START BRANCHLESS CONFIG # Avoid canceling the reference transaction in the case that `branchless` fails # for whatever reason. git branchless hook-reference-transaction "$@" || ( echo 'branchless: Failed to process reference transaction!' echo 'branchless: Some events (e.g. branch updates) may have been lost.' echo 'branchless: This is a bug. Please report it.' ) ## END BRANCHLESS CONFIG ```Events
Error: Could not find repository main branch
Version of
git-branchless
No response
Version of
git
No response