diff --git a/gitoxide-core/src/repository/tag.rs b/gitoxide-core/src/repository/tag.rs index 24f1572f1ef..5c41d05f1bf 100644 --- a/gitoxide-core/src/repository/tag.rs +++ b/gitoxide-core/src/repository/tag.rs @@ -1,5 +1,7 @@ use gix::bstr::{BStr, BString, ByteSlice}; +use crate::OutputFormat; + #[derive(Eq, PartialEq, PartialOrd, Ord)] enum VersionPart { String(BString), @@ -41,7 +43,11 @@ impl Version { } } -pub fn list(repo: gix::Repository, out: &mut dyn std::io::Write) -> anyhow::Result<()> { +pub fn list(repo: gix::Repository, out: &mut dyn std::io::Write, format: OutputFormat) -> anyhow::Result<()> { + if format != OutputFormat::Human { + anyhow::bail!("JSON output isn't supported"); + } + let platform = repo.references()?; let mut tags: Vec<_> = platform diff --git a/gix/src/lib.rs b/gix/src/lib.rs index 6c8d06f91dd..f753037d0fb 100644 --- a/gix/src/lib.rs +++ b/gix/src/lib.rs @@ -222,6 +222,24 @@ pub fn discover(directory: impl AsRef) -> Result, +) -> Result { + ThreadSafeRepository::discover_with_environment_overrides(directory).map(Into::into) +} + +/// See [`ThreadSafeRepository::open_with_environment_overrides()`], but returns a [`Repository`] instead. +/// +/// Use this method if you want a [`Repository`], but don't require it to be `Sync`. +#[allow(clippy::result_large_err)] +pub fn open_with_environment_overrides(directory: impl Into) -> Result { + ThreadSafeRepository::open_with_environment_overrides(directory, Default::default()).map(Into::into) +} + /// See [`ThreadSafeRepository::init()`], but returns a [`Repository`] instead. #[allow(clippy::result_large_err)] pub fn init(directory: impl AsRef) -> Result { diff --git a/gix/src/types.rs b/gix/src/types.rs index 4ada3d5c72d..1a9b0699959 100644 --- a/gix/src/types.rs +++ b/gix/src/types.rs @@ -145,7 +145,9 @@ pub struct Reference<'r> { /// A thread-local handle to interact with a repository from a single thread. /// -/// It is `Send` but **not** `Sync` - for the latter you can convert it `to_sync()`. +/// It is `Send`, but **not** `Sync` - for the latter you can convert it using +/// [`.into_sync()`][Repository::into_sync()]. +/// /// Note that it clones itself so that it is empty, requiring the user to configure each clone separately, specifically /// and explicitly. This is to have the fastest-possible default configuration available by default, but allow /// those who experiment with workloads to get speed boosts of 2x or more. diff --git a/src/plumbing/main.rs b/src/plumbing/main.rs index 12f2e5e7733..24148035056 100644 --- a/src/plumbing/main.rs +++ b/src/plumbing/main.rs @@ -1312,7 +1312,7 @@ pub fn main() -> Result<()> { progress, progress_keep_open, None, - move |_progress, out, _err| core::repository::tag::list(repository(Mode::Lenient)?, out), + move |_progress, out, _err| core::repository::tag::list(repository(Mode::Lenient)?, out, format), ), }, Subcommands::Tree(cmd) => match cmd {