mirror of
https://github.com/Llewellynvdm/starship.git
synced 2024-11-28 07:46:28 +00:00
fix(git_commit): remove unwraps (#2743)
This commit is contained in:
parent
c58d127974
commit
78b84c9f34
@ -46,13 +46,18 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
if !config.tag_disabled {
|
if !config.tag_disabled {
|
||||||
// Let's get repo tags names
|
// Let's get repo tags names
|
||||||
let tag_names = git_repo.tag_names(None).ok()?;
|
let tag_names = git_repo.tag_names(None).ok()?;
|
||||||
let tag_and_refs = tag_names.iter().flat_map(|name| {
|
let tag_and_refs = tag_names.iter().flatten().flat_map(|name| {
|
||||||
let full_tag = format!("refs/tags/{}", name.unwrap());
|
let full_tag = format!("refs/tags/{}", name);
|
||||||
let tag_obj = git_repo.find_reference(&full_tag)?.peel_to_tag()?;
|
let tag_obj = git_repo.find_reference(&full_tag)?.peel_to_tag()?;
|
||||||
let sig_obj = tag_obj.tagger().unwrap();
|
let sig_obj = tag_obj.tagger();
|
||||||
git_repo
|
git_repo.find_reference(&full_tag).map(|reference| {
|
||||||
.find_reference(&full_tag)
|
(
|
||||||
.map(|reference| (String::from(name.unwrap()), sig_obj.when(), reference))
|
String::from(name),
|
||||||
|
// fall back to oldest + 1s time if sig_obj is unavailable
|
||||||
|
sig_obj.map_or(git2::Time::new(1, 0), |s| s.when()),
|
||||||
|
reference,
|
||||||
|
)
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut tag_name = String::new();
|
let mut tag_name = String::new();
|
||||||
|
Loading…
Reference in New Issue
Block a user