Skip to content

Commit

Permalink
move commitgraph to 'free' (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Jul 22, 2022
1 parent 83585bd commit f99c3b2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 43 deletions.
44 changes: 22 additions & 22 deletions src/plumbing/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use gitoxide_core::pack::verify;
#[cfg(any(feature = "gitoxide-core-async-client", feature = "gitoxide-core-blocking-client"))]
use crate::plumbing::options::remote;
use crate::{
plumbing::options::{commitgraph, free, repo, Args, Subcommands},
plumbing::options::{free, repo, Args, Subcommands},
shared::pretty::prepare_and_run,
};

Expand Down Expand Up @@ -78,6 +78,27 @@ pub fn main() -> Result<()> {

match cmd {
Subcommands::Free(subcommands) => match subcommands {
free::Subcommands::CommitGraph(subcommands) => match subcommands {
free::commitgraph::Subcommands::Verify { path, statistics } => prepare_and_run(
"commitgraph-verify",
verbose,
progress,
progress_keep_open,
None,
move |_progress, out, err| {
let output_statistics = if statistics { Some(format) } else { None };
core::commitgraph::verify::graph_or_file(
path,
core::commitgraph::verify::Context {
err,
out,
output_statistics,
},
)
},
)
.map(|_| ()),
},
free::Subcommands::Index(free::index::Platform {
object_hash,
index_path,
Expand Down Expand Up @@ -635,27 +656,6 @@ pub fn main() -> Result<()> {
},
),
},
Subcommands::CommitGraph(subcommands) => match subcommands {
commitgraph::Subcommands::Verify { path, statistics } => prepare_and_run(
"commitgraph-verify",
verbose,
progress,
progress_keep_open,
None,
move |_progress, out, err| {
let output_statistics = if statistics { Some(format) } else { None };
core::commitgraph::verify::graph_or_file(
path,
core::commitgraph::verify::Context {
err,
out,
output_statistics,
},
)
},
)
.map(|_| ()),
},
}?;
Ok(())
}
Expand Down
41 changes: 20 additions & 21 deletions src/plumbing/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ pub enum Subcommands {
#[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),
/// Subcommands for interacting with entire git repositories
Repository(repo::Platform),
/// Subcommands that need no git repository to run.
Expand All @@ -69,6 +66,9 @@ pub enum Subcommands {
pub mod free {
#[derive(Debug, clap::Subcommand)]
pub enum Subcommands {
/// Subcommands for interacting with commit-graphs
#[clap(subcommand)]
CommitGraph(commitgraph::Subcommands),
/// Subcommands for interacting with mailmaps
Mailmap {
#[clap(flatten)]
Expand All @@ -81,6 +81,23 @@ pub mod free {
Index(index::Platform),
}

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

#[derive(Debug, clap::Subcommand)]
pub enum Subcommands {
/// Verify the integrity of a commit graph
Verify {
/// The path to '.git/objects/info/', '.git/objects/info/commit-graphs/', or '.git/objects/info/commit-graph' to validate.
path: PathBuf,
/// output statistical information about the pack
#[clap(long, short = 's')]
statistics: bool,
},
}
}

pub mod index {
use std::path::PathBuf;

Expand Down Expand Up @@ -585,24 +602,6 @@ pub mod repo {
}
}

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

#[derive(Debug, clap::Subcommand)]
pub enum Subcommands {
/// Verify the integrity of a commit graph
Verify {
/// The path to '.git/objects/info/', '.git/objects/info/commit-graphs/', or '.git/objects/info/commit-graph' to validate.
path: PathBuf,
/// output statistical information about the pack
#[clap(long, short = 's')]
statistics: bool,
},
}
}

///
#[cfg(any(feature = "gitoxide-core-async-client", feature = "gitoxide-core-blocking-client"))]
pub mod remote {
Expand Down

0 comments on commit f99c3b2

Please sign in to comment.