diff --git a/gitoxide-core/src/repository/remote.rs b/gitoxide-core/src/repository/remote.rs index 74b15c5faf5..345a12677e9 100644 --- a/gitoxide-core/src/repository/remote.rs +++ b/gitoxide-core/src/repository/remote.rs @@ -1,21 +1,30 @@ #[cfg(any(feature = "blocking-client", feature = "async-client"))] mod net { use crate::OutputFormat; - use anyhow::{bail, Context}; + use anyhow::bail; use git_repository as git; use git_repository::protocol::fetch; + pub mod refs { + use crate::OutputFormat; + + pub struct Context { + pub format: OutputFormat, + pub name: Option, + pub url: Option, + } + } + #[git::protocol::maybe_async::maybe_async] - pub async fn refs( + pub async fn refs_fn( repo: git::Repository, - name: Option<&str>, - url: Option, - format: OutputFormat, mut progress: impl git::Progress, out: impl std::io::Write, + refs::Context { format, name, url }: refs::Context, ) -> anyhow::Result<()> { + use anyhow::Context; let remote = match (name, url) { - (Some(name), None) => repo.find_remote(name)?, + (Some(name), None) => repo.find_remote(&name)?, (None, None) => repo .head()? .into_remote(git::remote::Direction::Fetch) @@ -101,4 +110,4 @@ mod net { } } #[cfg(any(feature = "blocking-client", feature = "async-client"))] -pub use net::refs; +pub use net::{refs, refs_fn as refs}; diff --git a/src/plumbing/main.rs b/src/plumbing/main.rs index d71a797b647..11df5cf6664 100644 --- a/src/plumbing/main.rs +++ b/src/plumbing/main.rs @@ -106,11 +106,9 @@ pub fn main() -> Result<()> { move |progress, out, _err| { core::repository::remote::refs( repository(Mode::Lenient)?, - name.as_deref(), - url, - format, progress, out, + core::repository::remote::refs::Context { name, url, format }, ) }, ) @@ -121,11 +119,9 @@ pub fn main() -> Result<()> { async_util::prepare(verbose, "remote-refs", Some(core::remote::refs::PROGRESS_RANGE)); futures_lite::future::block_on(core::repository::remote::refs( repository(Mode::Lenient)?, - name.as_deref(), - url, - format, progress, std::io::stdout(), + core::repository::remote::refs::Context { name, url, format }, )) } }