Skip to content

Commit 1750d96

Browse files
committed
Call gix::Tag::decode only once
1 parent f71ccc1 commit 1750d96

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

asyncgit/src/sync/tags.rs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,20 @@ pub fn get_tags(repo_path: &RepoPath) -> Result<Tags> {
6363
.map(Into::into)?;
6464
let platform = gix_repo.references()?;
6565
for mut reference in (platform.tags()?).flatten() {
66-
let commit = reference.peel_to_commit().ok();
67-
let tag = reference.peel_to_tag().ok();
68-
69-
if let Some(commit) = commit {
70-
let name = tag
71-
.as_ref()
72-
.and_then(|tag| {
73-
let tag_ref = tag.decode().ok();
74-
tag_ref.map(|tag_ref| tag_ref.name.to_string())
75-
})
76-
.unwrap_or_else(|| {
77-
reference.name().shorten().to_string()
78-
});
79-
let annotation = tag.and_then(|tag| {
80-
let tag_ref = tag.decode().ok();
81-
tag_ref.map(|tag_ref| tag_ref.message.to_string())
82-
});
66+
let commit = reference.peel_to_commit();
67+
let tag = reference.peel_to_tag();
68+
69+
if let Ok(commit) = commit {
70+
let tag_ref = tag.as_ref().map(gix::Tag::decode);
71+
72+
let name = match tag_ref {
73+
Ok(Ok(tag)) => tag.name.to_string(),
74+
_ => reference.name().shorten().to_string(),
75+
};
76+
let annotation = match tag_ref {
77+
Ok(Ok(tag)) => Some(tag.message.to_string()),
78+
_ => None,
79+
};
8380

8481
adder(commit.into(), Tag { name, annotation });
8582
}

0 commit comments

Comments
 (0)