fix: dont panic if git initialized without any remote

This commit is contained in:
Jozef Steinhübl 2024-07-24 07:04:04 +02:00
parent ab6fd3481d
commit bc8fea3e78
No known key found for this signature in database
GPG key ID: E6BC90C91973B08F

View file

@ -32,11 +32,12 @@ fn get_main_remote_url(repository: Repository) -> Option<String> {
} }
return match repository.remotes() { return match repository.remotes() {
Ok(remotes) => repository Ok(remotes) => remotes.get(0).and_then(|name| {
.find_remote(remotes.get(0).unwrap()) repository
.unwrap() .find_remote(name)
.url() .ok()
.map(|url| transform_url(url.to_string())), .and_then(|remote| remote.url().map(|url| transform_url(url.to_string())))
}),
Err(_) => None, Err(_) => None,
}; };
} }