Skip to content

Commit

Permalink
change!: remove gix free remote ref-list in favor of `gix remote re…
Browse files Browse the repository at this point in the history
…fs` (#450)

The functinality is the same, but the latter is built on top of a
repository which is slightly less flexible, but preferable over
maintaining a non-repo version.
  • Loading branch information
Byron committed Aug 22, 2022
1 parent 7d30eb3 commit dda9957
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 392 deletions.
2 changes: 0 additions & 2 deletions gitoxide-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ pub mod mailmap;
#[cfg(feature = "organize")]
pub mod organize;
pub mod pack;
#[cfg(any(feature = "async-client", feature = "blocking-client"))]
pub mod remote;
pub mod repository;

#[cfg(all(feature = "async-client", feature = "blocking-client"))]
Expand Down
6 changes: 3 additions & 3 deletions gitoxide-core/src/pack/receive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use git_repository::{
Progress,
};

use crate::{remote::refs::JsonRef, OutputFormat};
use crate::OutputFormat;

pub const PROGRESS_RANGE: std::ops::RangeInclusive<u8> = 1..=3;

Expand Down Expand Up @@ -272,7 +272,7 @@ pub struct JsonOutcome {
pub index_path: Option<PathBuf>,
pub data_path: Option<PathBuf>,

pub refs: Vec<JsonRef>,
pub refs: Vec<crate::repository::remote::JsonRef>,
}

impl JsonOutcome {
Expand All @@ -298,7 +298,7 @@ fn print(out: &mut impl io::Write, res: pack::bundle::write::Outcome, refs: &[Re
print_hash_and_path(out, "index", res.index.index_hash, res.index_path)?;
print_hash_and_path(out, "pack", res.index.data_hash, res.data_path)?;
writeln!(out)?;
crate::remote::refs::print(out, refs)?;
crate::repository::remote::refs::print(out, refs)?;
Ok(())
}

Expand Down
1 change: 0 additions & 1 deletion gitoxide-core/src/remote/mod.rs

This file was deleted.

64 changes: 0 additions & 64 deletions gitoxide-core/src/remote/refs/async_io.rs

This file was deleted.

51 changes: 0 additions & 51 deletions gitoxide-core/src/remote/refs/blocking_io.rs

This file was deleted.

110 changes: 0 additions & 110 deletions gitoxide-core/src/remote/refs/mod.rs

This file was deleted.

6 changes: 5 additions & 1 deletion gitoxide-core/src/repository/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ mod net {
pub mod refs {
use crate::OutputFormat;

pub const PROGRESS_RANGE: std::ops::RangeInclusive<u8> = 1..=2;

pub struct Context {
pub format: OutputFormat,
pub name: Option<String>,
pub url: Option<git_repository::Url>,
}

pub(crate) use super::print;
}

#[git::protocol::maybe_async::maybe_async]
Expand Down Expand Up @@ -110,4 +114,4 @@ mod net {
}
}
#[cfg(any(feature = "blocking-client", feature = "async-client"))]
pub use net::{refs, refs_fn as refs};
pub use net::{refs, refs_fn as refs, JsonRef};
47 changes: 6 additions & 41 deletions src/plumbing/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pub fn main() -> Result<()> {
verbose,
progress,
progress_keep_open,
None,
core::repository::remote::refs::PROGRESS_RANGE,
move |progress, out, _err| {
core::repository::remote::refs(
repository(Mode::Lenient)?,
Expand All @@ -122,8 +122,11 @@ pub fn main() -> Result<()> {
}
#[cfg(feature = "gitoxide-core-async-client")]
{
let (_handle, progress) =
async_util::prepare(verbose, "remote-refs", Some(core::remote::refs::PROGRESS_RANGE));
let (_handle, progress) = async_util::prepare(
verbose,
"remote-refs",
Some(core::repository::remote::refs::PROGRESS_RANGE),
);
futures_lite::future::block_on(core::repository::remote::refs(
repository(Mode::Lenient)?,
progress,
Expand All @@ -143,44 +146,6 @@ pub fn main() -> Result<()> {
)
.map(|_| ()),
Subcommands::Free(subcommands) => match subcommands {
#[cfg(any(feature = "gitoxide-core-async-client", feature = "gitoxide-core-blocking-client"))]
free::Subcommands::Remote(subcommands) => match subcommands {
#[cfg(feature = "gitoxide-core-async-client")]
free::remote::Subcommands::RefList { protocol, url } => {
let (_handle, progress) =
async_util::prepare(verbose, "remote-ref-list", Some(core::remote::refs::PROGRESS_RANGE));
futures_lite::future::block_on(core::remote::refs::list(
protocol,
&url,
progress,
core::remote::refs::Context {
thread_limit,
format,
out: std::io::stdout(),
},
))
}
#[cfg(feature = "gitoxide-core-blocking-client")]
free::remote::Subcommands::RefList { protocol, url } => prepare_and_run(
"remote-ref-list",
verbose,
progress,
progress_keep_open,
core::remote::refs::PROGRESS_RANGE,
move |progress, out, _err| {
core::remote::refs::list(
protocol,
&url,
progress,
core::remote::refs::Context {
thread_limit,
format,
out,
},
)
},
),
},
free::Subcommands::CommitGraph(subcommands) => match subcommands {
free::commitgraph::Subcommands::Verify { path, statistics } => prepare_and_run(
"commitgraph-verify",
Expand Down
28 changes: 0 additions & 28 deletions src/plumbing/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,6 @@ pub mod free {
#[derive(Debug, clap::Subcommand)]
#[clap(visible_alias = "no-repo")]
pub enum Subcommands {
/// Subcommands for interacting with git remote server.
#[clap(subcommand)]
#[cfg(any(feature = "gitoxide-core-async-client", feature = "gitoxide-core-blocking-client"))]
Remote(remote::Subcommands),
/// Subcommands for interacting with commit-graphs
#[clap(subcommand)]
CommitGraph(commitgraph::Subcommands),
Expand All @@ -270,30 +266,6 @@ pub mod free {
Index(index::Platform),
}

///
#[cfg(any(feature = "gitoxide-core-async-client", feature = "gitoxide-core-blocking-client"))]
pub mod remote {
use gitoxide_core as core;

#[derive(Debug, clap::Subcommand)]
pub enum Subcommands {
/// List remote references from a remote identified by a url.
///
/// This is the plumbing equivalent of `git ls-remote`.
/// Supported URLs are documented here: <https://www.git-scm.com/docs/git-clone#_git_urls>
RefList {
/// The protocol version to use. Valid values are 1 and 2
#[clap(long, short = 'p')]
protocol: Option<core::net::Protocol>,

/// the URLs or path from which to receive references
///
/// See here for a list of supported URLs: <https://www.git-scm.com/docs/git-clone#_git_urls>
url: String,
},
}
}

///
pub mod commitgraph {
use std::path::PathBuf;
Expand Down

0 comments on commit dda9957

Please sign in to comment.