+
Skip to content

Conversation

9p4
Copy link
Contributor

@9p4 9p4 commented Apr 6, 2025

Resolves #131

fn find_default_branch(repo: &gix::Repository) -> Result<Option<String>, anyhow::Error> {
Ok(Some(repo.head()?.name().as_bstr().to_string()))
if repo.head()?.is_detached() {
Ok(None)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is redundant because referent_name already checks if detached and returns None so could've been written:

let head = repo.head()?;

let Some(referent) = head.referent_name() else {
    return Ok(None);
};

Ok(Some(referent.as_bstr().to_string()))

Not a huge issue though. Thanks for the contribution

@w4 w4 merged commit 551253a into w4:main Apr 7, 2025
1 check passed
@9p4 9p4 deleted the fix-default-branch-detection branch April 7, 2025 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect default branch detection

2 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载