Skip to content

Commit 37d3bf2

Browse files
committed
feat: add first debug version of gix tag list
1 parent dab97f7 commit 37d3bf2

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

gitoxide-core/src/repository/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ pub mod remote;
4444
pub mod revision;
4545
pub mod status;
4646
pub mod submodule;
47+
pub mod tag;
4748
pub mod tree;
4849
pub mod verify;
4950
pub mod worktree;

gitoxide-core/src/repository/tag.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
pub fn list(repo: gix::Repository, out: &mut dyn std::io::Write) -> anyhow::Result<()> {
2+
let platform = repo.references()?;
3+
4+
for mut reference in (platform.tags()?).flatten() {
5+
let tag = reference.peel_to_tag();
6+
let tag_ref = tag.as_ref().map(gix::Tag::decode);
7+
8+
let name = match tag_ref {
9+
Ok(Ok(tag)) => tag.name.to_string(),
10+
_ => reference.name().shorten().to_string(),
11+
};
12+
13+
writeln!(out, "{name}")?;
14+
}
15+
16+
Ok(())
17+
}

src/plumbing/main.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::{
1717
plumbing::{
1818
options::{
1919
attributes, commit, commitgraph, config, credential, exclude, free, fsck, index, mailmap, merge, odb,
20-
revision, tree, Args, Subcommands,
20+
revision, tag, tree, Args, Subcommands,
2121
},
2222
show_progress,
2323
},
@@ -1304,6 +1304,17 @@ pub fn main() -> Result<()> {
13041304
},
13051305
),
13061306
},
1307+
Subcommands::Tag(cmd) => match cmd {
1308+
tag::Subcommands::List => prepare_and_run(
1309+
"tag-list",
1310+
trace,
1311+
auto_verbose,
1312+
progress,
1313+
progress_keep_open,
1314+
None,
1315+
move |_progress, out, _err| core::repository::tag::list(repository(Mode::Lenient)?, out),
1316+
),
1317+
},
13071318
Subcommands::Tree(cmd) => match cmd {
13081319
tree::Subcommands::Entries {
13091320
treeish,

src/plumbing/options/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ pub enum Subcommands {
100100
/// Interact with commit objects.
101101
#[clap(subcommand)]
102102
Commit(commit::Subcommands),
103+
/// Interact with tag objects.
104+
#[clap(subcommand)]
105+
Tag(tag::Subcommands),
103106
/// Verify the integrity of the entire repository
104107
Verify {
105108
#[clap(flatten)]
@@ -928,6 +931,14 @@ pub mod commit {
928931
}
929932
}
930933

934+
pub mod tag {
935+
#[derive(Debug, clap::Subcommand)]
936+
pub enum Subcommands {
937+
/// List all tags.
938+
List,
939+
}
940+
}
941+
931942
pub mod credential {
932943
#[derive(Debug, clap::Subcommand)]
933944
pub enum Subcommands {

0 commit comments

Comments
 (0)