nickgerace / gfold

CLI tool to help keep track of your Git repositories, written in Rust
https://crates.io/crates/gfold
Apache License 2.0
283 stars 20 forks source link

Error: no reference found for shorthand 'origin/HEAD' #202

Closed BerkeleyTrue closed 1 year ago

BerkeleyTrue commented 2 years ago

After updating to 4.0 recently I started experiencing this issue.

Error: no reference found for shorthand 'origin/HEAD'; class=Reference (4); code=NotFound (-3)

image

Downgrading back to 3.0 doesn't show the same issue image

I saw there was a PR for a similar issue that was merged in quite some time ago. Did that not make it into the new release?

nickgerace commented 2 years ago

Ah yes, I thought it had been fixed with #192 or another issue that I am not recalling at the moment. Thanks for filing the issue; I'll look into it.

Would you mind running with RUST_LOG=debug RUST_BACKTRACE=1 gfold? Please feel free to redact any sensitive information, though I doubt that'll be the case.

BerkeleyTrue commented 2 years ago

@nickgerace Here is the output in a gist

https://gist.github.com/BerkeleyTrue/b9699f9dbd27e6b11e71ce57b314d2a6

AckslD commented 2 years ago

I'm also still seeing this issue when the remote is something else then origin.

nickgerace commented 2 years ago

Thank you @BerkeleyTrue and @AckslD. I'll try to catch this bug by adjusting the integration test payload and see what I can do.

AckslD commented 1 year ago

@nickgerace I made an attempt to add a failing test reproducing this in #210. My rust skills are not very high but I hope it can help to find the underlying issue :)

nickgerace commented 1 year ago

Merged #210 and going to look further. CI needs to catch this as well if it does not.

nickgerace commented 1 year ago

Thank to @AckslD's PR, I think I figured it out.

The app tries to determine if a repository (with its current checked out branch) is in the "unpushed" state by checking if the local branch has a corresponding remote. If it does, then we check if the commits match. If it doesn't then we assume that the state is "unpushed". The problem here was in the latter check. During that check, we try to resolve the reference with a given short name, but we would fail if we could not. Well, if a remote branch doesn't exist with that short name (e.g. origin/HEAD), then we will always fail, which is undesired behavior. I believe #215 should solve the issue.

EDIT: if #215 did not solve the problem, I'll re-open this issue.

AckslD commented 1 year ago

Thanks @nickgerace, things seem to indeed work now for me :)

nickgerace commented 1 year ago

Glad to hear!