Skip to content

Commit

Permalink
move 'commit' up one level (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Jul 22, 2022
1 parent ac7d99a commit 72876f1
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 80 deletions.
72 changes: 36 additions & 36 deletions src/plumbing/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use git_repository::bstr::io::BufReadExt;
use gitoxide_core as core;
use gitoxide_core::pack::verify;

use crate::plumbing::options::revision;
use crate::plumbing::options::{commit, revision};
use crate::{
plumbing::options::{free, repo, Args, Subcommands},
shared::pretty::prepare_and_run,
Expand Down Expand Up @@ -513,42 +513,42 @@ pub fn main() -> Result<()> {
move |_progress, out, _err| core::repository::revision::explain(repository()?.into(), spec, out),
),
},
Subcommands::Commit { cmd } => match cmd {
commit::Subcommands::Describe {
annotated_tags,
all_refs,
first_parent,
always,
long,
statistics,
max_candidates,
rev_spec,
} => prepare_and_run(
"repository-commit-describe",
verbose,
progress,
progress_keep_open,
None,
move |_progress, out, err| {
core::repository::commit::describe(
repository()?.into(),
rev_spec.as_deref(),
out,
err,
core::repository::commit::describe::Options {
all_tags: !annotated_tags,
all_refs,
long_format: long,
first_parent,
statistics,
max_candidates,
always,
},
)
},
),
},
Subcommands::Repository(repo::Platform { cmd }) => match cmd {
repo::Subcommands::Commit { cmd } => match cmd {
repo::commit::Subcommands::Describe {
annotated_tags,
all_refs,
first_parent,
always,
long,
statistics,
max_candidates,
rev_spec,
} => prepare_and_run(
"repository-commit-describe",
verbose,
progress,
progress_keep_open,
None,
move |_progress, out, err| {
core::repository::commit::describe(
repository()?.into(),
rev_spec.as_deref(),
out,
err,
core::repository::commit::describe::Options {
all_tags: !annotated_tags,
all_refs,
long_format: long,
first_parent,
statistics,
max_candidates,
always,
},
)
},
),
},
repo::Subcommands::Exclude { cmd } => match cmd {
repo::exclude::Subcommands::Query {
patterns,
Expand Down
88 changes: 44 additions & 44 deletions src/plumbing/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ pub struct Args {

#[derive(Debug, clap::Subcommand)]
pub enum Subcommands {
/// Interact with commit objects.
Commit {
#[clap(subcommand)]
cmd: commit::Subcommands,
},
/// Verify the integrity of the entire repository
Verify {
#[clap(flatten)]
Expand All @@ -68,6 +73,45 @@ pub enum Subcommands {
Free(free::Subcommands),
}

pub mod commit {
#[derive(Debug, clap::Subcommand)]
pub enum Subcommands {
/// Describe the current commit or the given one using the name of the closest annotated tag in its ancestry.
Describe {
/// Use annotated tag references only, not all tags.
#[clap(long, short = 't', conflicts_with("all-refs"))]
annotated_tags: bool,

/// Use all references under the `ref/` namespaces, which includes tag references, local and remote branches.
#[clap(long, short = 'a', conflicts_with("annotated-tags"))]
all_refs: bool,

/// Only follow the first parent when traversing the commit graph.
#[clap(long, short = 'f')]
first_parent: bool,

/// Always display the long format, even if that would not be necessary as the id is located directly on a reference.
#[clap(long, short = 'l')]
long: bool,

/// Consider only the given `n` candidates. This can take longer, but potentially produces more accurate results.
#[clap(long, short = 'c', default_value = "10")]
max_candidates: usize,

/// Print information on stderr to inform about performance statistics
#[clap(long, short = 's')]
statistics: bool,

#[clap(long)]
/// If there was no way to describe the commit, fallback to using the abbreviated input revision.
always: bool,

/// A specification of the revision to use, or the current `HEAD` if unset.
rev_spec: Option<String>,
},
}
}

pub mod revision {
#[derive(Debug, clap::Subcommand)]
#[clap(visible_alias = "rev")]
Expand Down Expand Up @@ -488,11 +532,6 @@ pub mod repo {
#[derive(Debug, clap::Subcommand)]
#[clap(visible_alias = "repo")]
pub enum Subcommands {
/// Interact with commit objects.
Commit {
#[clap(subcommand)]
cmd: commit::Subcommands,
},
/// Interact with tree objects.
Tree {
#[clap(subcommand)]
Expand Down Expand Up @@ -559,45 +598,6 @@ pub mod repo {
}
}

pub mod commit {
#[derive(Debug, clap::Subcommand)]
pub enum Subcommands {
/// Describe the current commit or the given one using the name of the closest annotated tag in its ancestry.
Describe {
/// Use annotated tag references only, not all tags.
#[clap(long, short = 't', conflicts_with("all-refs"))]
annotated_tags: bool,

/// Use all references under the `ref/` namespaces, which includes tag references, local and remote branches.
#[clap(long, short = 'a', conflicts_with("annotated-tags"))]
all_refs: bool,

/// Only follow the first parent when traversing the commit graph.
#[clap(long, short = 'f')]
first_parent: bool,

/// Always display the long format, even if that would not be necessary as the id is located directly on a reference.
#[clap(long, short = 'l')]
long: bool,

/// Consider only the given `n` candidates. This can take longer, but potentially produces more accurate results.
#[clap(long, short = 'c', default_value = "10")]
max_candidates: usize,

/// Print information on stderr to inform about performance statistics
#[clap(long, short = 's')]
statistics: bool,

#[clap(long)]
/// If there was no way to describe the commit, fallback to using the abbreviated input revision.
always: bool,

/// A specification of the revision to use, or the current `HEAD` if unset.
rev_spec: Option<String>,
},
}
}

pub mod tree {
#[derive(Debug, clap::Subcommand)]
pub enum Subcommands {
Expand Down

0 comments on commit 72876f1

Please sign in to comment.