Skip to content

Commit

Permalink
migrate mailmap to the new 'free' section (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Jul 22, 2022
1 parent f4e1810 commit 141c5f1
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 35 deletions.
24 changes: 13 additions & 11 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, index, mailmap, pack, pack::multi_index, repo, Args, Subcommands},
plumbing::options::{commitgraph, free, index, pack, pack::multi_index, repo, Args, Subcommands},
shared::pretty::prepare_and_run,
};

Expand Down Expand Up @@ -77,16 +77,6 @@ pub fn main() -> Result<()> {
})?;

match cmd {
Subcommands::Mailmap(mailmap::Platform { path, cmd }) => match cmd {
mailmap::Subcommands::Verify => prepare_and_run(
"mailmap-verify",
verbose,
progress,
progress_keep_open,
core::mailmap::PROGRESS_RANGE,
move |_progress, out, _err| core::mailmap::verify(path, format, out),
),
},
Subcommands::Index(index::Platform {
object_hash,
index_path,
Expand Down Expand Up @@ -159,6 +149,18 @@ pub fn main() -> Result<()> {
},
),
},
Subcommands::Free(free::Subcommands::Mailmap { cmd }) => match cmd {
free::mailmap::Platform { path, cmd } => match cmd {
free::mailmap::Subcommands::Verify => prepare_and_run(
"mailmap-verify",
verbose,
progress,
progress_keep_open,
core::mailmap::PROGRESS_RANGE,
move |_progress, out, _err| core::mailmap::verify(path, format, out),
),
},
},
Subcommands::Repository(repo::Platform { cmd }) => match cmd {
repo::Subcommands::Revision { cmd } => match cmd {
repo::revision::Subcommands::Explain { spec } => prepare_and_run(
Expand Down
61 changes: 37 additions & 24 deletions src/plumbing/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ pub enum Subcommands {
Index(index::Platform),
/// Subcommands for interacting with entire git repositories
Repository(repo::Platform),
/// Subcommands for interacting with mailmaps
Mailmap(mailmap::Platform),
/// Subcommands that need no git repository to run.
#[clap(subcommand)]
Free(free::Subcommands),
}

///
Expand Down Expand Up @@ -332,6 +333,40 @@ pub mod pack {
}
}

///
pub mod free {
#[derive(Debug, clap::Subcommand)]
pub enum Subcommands {
/// Subcommands for interacting with mailmaps
Mailmap {
#[clap(flatten)]
cmd: mailmap::Platform,
},
}

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

#[derive(Debug, clap::Parser)]
pub struct Platform {
/// The path to the mailmap file.
#[clap(short = 'p', long, default_value = ".mailmap")]
pub path: PathBuf,

/// Subcommands
#[clap(subcommand)]
pub cmd: Subcommands,
}

#[derive(Debug, clap::Subcommand)]
pub enum Subcommands {
/// Parse all entries in the mailmap and report malformed lines or collisions.
Verify,
}
}
}

///
pub mod repo {
#[derive(Debug, clap::Parser)]
Expand Down Expand Up @@ -551,28 +586,6 @@ pub mod index {
}
}

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

#[derive(Debug, clap::Parser)]
pub struct Platform {
/// The path to the mailmap file.
#[clap(short = 'p', long, default_value = ".mailmap")]
pub path: PathBuf,

/// Subcommands
#[clap(subcommand)]
pub cmd: Subcommands,
}

#[derive(Debug, clap::Subcommand)]
pub enum Subcommands {
/// Parse all entries in the mailmap and report malformed lines or collisions.
Verify,
}
}

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

0 comments on commit 141c5f1

Please sign in to comment.