-
Notifications
You must be signed in to change notification settings - Fork 1
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
find remote reference when HEAD detached #48
Conversation
src/scanner.rs
Outdated
if id.is_some() && id.unwrap().to_string() == git_head_id.to_string() { | ||
git_head_branch = | ||
Some(r.name().to_path().to_str().unwrap().to_string()); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sure there's a more elegant solution here. If there is, any pointers would be greatly appreciated.
💊 0 quarantined ✅ 10 passed 🕐 10 new ⋅ (learn more) |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but not sure we need to match or warn. Just a suggestion, but we could do something like this as well
if git_head_branch.is_none() {
for rb in git_repo.references()?.remote_branches()? {
git_head_branch = rb.map_or(None, |r| {
let id = r.target().try_id().map(|id| id.to_string());
let git_head_id = git_head.id().map(|id| id.to_string());
if id.is_some() && git_head_id.is_some() && id == git_head_id {
return r.name().to_path().to_str().map(|s| s.to_string());
}
None
});
}
}
Signed-off-by: Gabe <78751069+gnalh@users.noreply.github.com>
Scan the references to find the matching reference name. This is equivalent to
git for-each-ref --contains e0c6eaa19870c1ae30601bed5bee604c7436c9a2
After:
Before
Repro: