Skip to content

Commit a845a4b

Browse files
committed
Make output more verbose
1 parent 37d3bf2 commit a845a4b

File tree

1 file changed

+19
-5
lines changed
  • gitoxide-core/src/repository

1 file changed

+19
-5
lines changed

gitoxide-core/src/repository/tag.rs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,26 @@ pub fn list(repo: gix::Repository, out: &mut dyn std::io::Write) -> anyhow::Resu
55
let tag = reference.peel_to_tag();
66
let tag_ref = tag.as_ref().map(gix::Tag::decode);
77

8-
let name = match tag_ref {
9-
Ok(Ok(tag)) => tag.name.to_string(),
10-
_ => reference.name().shorten().to_string(),
11-
};
8+
// `name` is the name of the file in `refs/tags/`. This applies to both lightweight as well
9+
// as annotated tags.
10+
let name = reference.name().shorten();
1211

13-
writeln!(out, "{name}")?;
12+
match tag_ref {
13+
Ok(Ok(tag_ref)) => {
14+
// `tag_name` is the name provided by the user via `git tag -a/-s/-u`. It is only
15+
// present for annotated tags.
16+
let tag_name = tag_ref.name;
17+
18+
if name == tag_name {
19+
writeln!(out, "{name} *")?;
20+
} else {
21+
writeln!(out, "{name} [tag name: {}]", tag_ref.name)?;
22+
}
23+
}
24+
_ => {
25+
writeln!(out, "{name}")?;
26+
}
27+
}
1428
}
1529

1630
Ok(())

0 commit comments

Comments
 (0)