mirror of
https://github.com/xHyroM/zed-discord-presence.git
synced 2024-11-24 14:51:07 +01:00
fix: dont panic if git initialized without any remote
This commit is contained in:
parent
ab6fd3481d
commit
bc8fea3e78
1 changed files with 6 additions and 5 deletions
|
@ -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,
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue