Skip to content

Commit 72876f1

Browse files
committed
move 'commit' up one level (#331)
1 parent ac7d99a commit 72876f1

File tree

2 files changed

+80
-80
lines changed

2 files changed

+80
-80
lines changed

Diff for: src/plumbing/main.rs

+36-36
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use git_repository::bstr::io::BufReadExt;
1313
use gitoxide_core as core;
1414
use gitoxide_core::pack::verify;
1515

16-
use crate::plumbing::options::revision;
16+
use crate::plumbing::options::{commit, revision};
1717
use crate::{
1818
plumbing::options::{free, repo, Args, Subcommands},
1919
shared::pretty::prepare_and_run,
@@ -513,42 +513,42 @@ pub fn main() -> Result<()> {
513513
move |_progress, out, _err| core::repository::revision::explain(repository()?.into(), spec, out),
514514
),
515515
},
516+
Subcommands::Commit { cmd } => match cmd {
517+
commit::Subcommands::Describe {
518+
annotated_tags,
519+
all_refs,
520+
first_parent,
521+
always,
522+
long,
523+
statistics,
524+
max_candidates,
525+
rev_spec,
526+
} => prepare_and_run(
527+
"repository-commit-describe",
528+
verbose,
529+
progress,
530+
progress_keep_open,
531+
None,
532+
move |_progress, out, err| {
533+
core::repository::commit::describe(
534+
repository()?.into(),
535+
rev_spec.as_deref(),
536+
out,
537+
err,
538+
core::repository::commit::describe::Options {
539+
all_tags: !annotated_tags,
540+
all_refs,
541+
long_format: long,
542+
first_parent,
543+
statistics,
544+
max_candidates,
545+
always,
546+
},
547+
)
548+
},
549+
),
550+
},
516551
Subcommands::Repository(repo::Platform { cmd }) => match cmd {
517-
repo::Subcommands::Commit { cmd } => match cmd {
518-
repo::commit::Subcommands::Describe {
519-
annotated_tags,
520-
all_refs,
521-
first_parent,
522-
always,
523-
long,
524-
statistics,
525-
max_candidates,
526-
rev_spec,
527-
} => prepare_and_run(
528-
"repository-commit-describe",
529-
verbose,
530-
progress,
531-
progress_keep_open,
532-
None,
533-
move |_progress, out, err| {
534-
core::repository::commit::describe(
535-
repository()?.into(),
536-
rev_spec.as_deref(),
537-
out,
538-
err,
539-
core::repository::commit::describe::Options {
540-
all_tags: !annotated_tags,
541-
all_refs,
542-
long_format: long,
543-
first_parent,
544-
statistics,
545-
max_candidates,
546-
always,
547-
},
548-
)
549-
},
550-
),
551-
},
552552
repo::Subcommands::Exclude { cmd } => match cmd {
553553
repo::exclude::Subcommands::Query {
554554
patterns,

Diff for: src/plumbing/options.rs

+44-44
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ pub struct Args {
5151

5252
#[derive(Debug, clap::Subcommand)]
5353
pub enum Subcommands {
54+
/// Interact with commit objects.
55+
Commit {
56+
#[clap(subcommand)]
57+
cmd: commit::Subcommands,
58+
},
5459
/// Verify the integrity of the entire repository
5560
Verify {
5661
#[clap(flatten)]
@@ -68,6 +73,45 @@ pub enum Subcommands {
6873
Free(free::Subcommands),
6974
}
7075

76+
pub mod commit {
77+
#[derive(Debug, clap::Subcommand)]
78+
pub enum Subcommands {
79+
/// Describe the current commit or the given one using the name of the closest annotated tag in its ancestry.
80+
Describe {
81+
/// Use annotated tag references only, not all tags.
82+
#[clap(long, short = 't', conflicts_with("all-refs"))]
83+
annotated_tags: bool,
84+
85+
/// Use all references under the `ref/` namespaces, which includes tag references, local and remote branches.
86+
#[clap(long, short = 'a', conflicts_with("annotated-tags"))]
87+
all_refs: bool,
88+
89+
/// Only follow the first parent when traversing the commit graph.
90+
#[clap(long, short = 'f')]
91+
first_parent: bool,
92+
93+
/// Always display the long format, even if that would not be necessary as the id is located directly on a reference.
94+
#[clap(long, short = 'l')]
95+
long: bool,
96+
97+
/// Consider only the given `n` candidates. This can take longer, but potentially produces more accurate results.
98+
#[clap(long, short = 'c', default_value = "10")]
99+
max_candidates: usize,
100+
101+
/// Print information on stderr to inform about performance statistics
102+
#[clap(long, short = 's')]
103+
statistics: bool,
104+
105+
#[clap(long)]
106+
/// If there was no way to describe the commit, fallback to using the abbreviated input revision.
107+
always: bool,
108+
109+
/// A specification of the revision to use, or the current `HEAD` if unset.
110+
rev_spec: Option<String>,
111+
},
112+
}
113+
}
114+
71115
pub mod revision {
72116
#[derive(Debug, clap::Subcommand)]
73117
#[clap(visible_alias = "rev")]
@@ -488,11 +532,6 @@ pub mod repo {
488532
#[derive(Debug, clap::Subcommand)]
489533
#[clap(visible_alias = "repo")]
490534
pub enum Subcommands {
491-
/// Interact with commit objects.
492-
Commit {
493-
#[clap(subcommand)]
494-
cmd: commit::Subcommands,
495-
},
496535
/// Interact with tree objects.
497536
Tree {
498537
#[clap(subcommand)]
@@ -559,45 +598,6 @@ pub mod repo {
559598
}
560599
}
561600

562-
pub mod commit {
563-
#[derive(Debug, clap::Subcommand)]
564-
pub enum Subcommands {
565-
/// Describe the current commit or the given one using the name of the closest annotated tag in its ancestry.
566-
Describe {
567-
/// Use annotated tag references only, not all tags.
568-
#[clap(long, short = 't', conflicts_with("all-refs"))]
569-
annotated_tags: bool,
570-
571-
/// Use all references under the `ref/` namespaces, which includes tag references, local and remote branches.
572-
#[clap(long, short = 'a', conflicts_with("annotated-tags"))]
573-
all_refs: bool,
574-
575-
/// Only follow the first parent when traversing the commit graph.
576-
#[clap(long, short = 'f')]
577-
first_parent: bool,
578-
579-
/// Always display the long format, even if that would not be necessary as the id is located directly on a reference.
580-
#[clap(long, short = 'l')]
581-
long: bool,
582-
583-
/// Consider only the given `n` candidates. This can take longer, but potentially produces more accurate results.
584-
#[clap(long, short = 'c', default_value = "10")]
585-
max_candidates: usize,
586-
587-
/// Print information on stderr to inform about performance statistics
588-
#[clap(long, short = 's')]
589-
statistics: bool,
590-
591-
#[clap(long)]
592-
/// If there was no way to describe the commit, fallback to using the abbreviated input revision.
593-
always: bool,
594-
595-
/// A specification of the revision to use, or the current `HEAD` if unset.
596-
rev_spec: Option<String>,
597-
},
598-
}
599-
}
600-
601601
pub mod tree {
602602
#[derive(Debug, clap::Subcommand)]
603603
pub enum Subcommands {

0 commit comments

Comments
 (0)