Skip to content

Commit

Permalink
fix: dont panic if git initialized without any remote
Browse files Browse the repository at this point in the history
  • Loading branch information
xhyrom committed Jul 24, 2024
1 parent ab6fd34 commit bc8fea3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lsp/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ fn get_main_remote_url(repository: Repository) -> Option<String> {
}

return match repository.remotes() {
Ok(remotes) => repository
.find_remote(remotes.get(0).unwrap())
.unwrap()
.url()
.map(|url| transform_url(url.to_string())),
Ok(remotes) => remotes.get(0).and_then(|name| {
repository
.find_remote(name)
.ok()
.and_then(|remote| remote.url().map(|url| transform_url(url.to_string())))
}),
Err(_) => None,
};
}
Expand Down

0 comments on commit bc8fea3

Please sign in to comment.