Skip to content

Commit fb2766b

Browse files
cruesslerByron
authored andcommitted
Fail gix tag list when JSON is requested
1 parent fa1287f commit fb2766b

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

gitoxide-core/src/repository/tag.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use gix::bstr::{BStr, BString, ByteSlice};
22

3+
use crate::OutputFormat;
4+
35
#[derive(Eq, PartialEq, PartialOrd, Ord)]
46
enum VersionPart {
57
String(BString),
@@ -41,7 +43,11 @@ impl Version {
4143
}
4244
}
4345

44-
pub fn list(repo: gix::Repository, out: &mut dyn std::io::Write) -> anyhow::Result<()> {
46+
pub fn list(repo: gix::Repository, out: &mut dyn std::io::Write, format: OutputFormat) -> anyhow::Result<()> {
47+
if format != OutputFormat::Human {
48+
anyhow::bail!("JSON output isn't supported");
49+
}
50+
4551
let platform = repo.references()?;
4652

4753
let mut tags: Vec<_> = platform

gix/src/discover.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::path::Path;
33

44
pub use gix_discover::*;
55

6-
use crate::{bstr::BString, Repository, ThreadSafeRepository};
6+
use crate::{bstr::BString, ThreadSafeRepository};
77

88
/// The error returned by [`crate::discover()`].
99
#[derive(Debug, thiserror::Error)]

src/plumbing/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@ pub fn main() -> Result<()> {
13121312
progress,
13131313
progress_keep_open,
13141314
None,
1315-
move |_progress, out, _err| core::repository::tag::list(repository(Mode::Lenient)?, out),
1315+
move |_progress, out, _err| core::repository::tag::list(repository(Mode::Lenient)?, out, format),
13161316
),
13171317
},
13181318
Subcommands::Tree(cmd) => match cmd {

0 commit comments

Comments
 (0)