|
1 | 1 | pub fn list(repo: gix::Repository, out: &mut dyn std::io::Write) -> anyhow::Result<()> {
|
2 | 2 | let platform = repo.references()?;
|
3 | 3 |
|
4 |
| - for mut reference in (platform.tags()?).flatten() { |
| 4 | + for mut reference in platform.tags()?.flatten() { |
5 | 5 | let tag = reference.peel_to_tag();
|
6 | 6 | let tag_ref = tag.as_ref().map(gix::Tag::decode);
|
7 | 7 |
|
8 |
| - // `name` is the name of the file in `refs/tags/`. This applies to both lightweight as well |
9 |
| - // as annotated tags. |
| 8 | + // `name` is the name of the file in `refs/tags/`. |
| 9 | + // This applies to both lightweight and annotated tags. |
10 | 10 | let name = reference.name().shorten();
|
11 |
| - |
| 11 | + let mut fields = Vec::new(); |
12 | 12 | match tag_ref {
|
13 | 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)?; |
| 14 | + // `tag_name` is the name provided by the user via `git tag -a/-s/-u`. |
| 15 | + // It is only present for annotated tags. |
| 16 | + fields.push(format!( |
| 17 | + "tag name: {}", |
| 18 | + if name == tag_ref.name { "*".into() } else { tag_ref.name } |
| 19 | + )); |
| 20 | + if tag_ref.pgp_signature.is_some() { |
| 21 | + fields.push("signed".into()); |
22 | 22 | }
|
| 23 | + |
| 24 | + writeln!(out, "{name} [{fields}]", fields = fields.join(", "))?; |
23 | 25 | }
|
24 | 26 | _ => {
|
25 | 27 | writeln!(out, "{name}")?;
|
|
0 commit comments