Do not return error if git repository is in detached HEAD
Diff
src/database/indexer.rs | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
@@ -97,13 +97,17 @@
}
fn find_default_branch(repo: &gix::Repository) -> Result<Option<String>, anyhow::Error> {
Ok(Some(
repo.head()?
.referent_name()
.context("HEAD does not point to anything")?
.as_bstr()
.to_string(),
))
if repo.head()?.is_detached() {
Ok(None)
} else {
Ok(Some(
repo.head()?
.referent_name()
.context("HEAD does not point to anything")?
.as_bstr()
.to_string(),
))
}
}
fn find_last_committed_time(repo: &gix::Repository) -> Result<OffsetDateTime, anyhow::Error> {