diff --git a/src/ein.rs b/src/ein.rs index bfb4ba4716d..ebcfa5a9965 100644 --- a/src/ein.rs +++ b/src/ein.rs @@ -1,11 +1,8 @@ #![deny(rust_2018_idioms, unsafe_code)] mod porcelain; -mod shared; -use anyhow::Result; - -fn main() -> Result<()> { +fn main() -> anyhow::Result<()> { porcelain::main() } diff --git a/src/lib.rs b/src/lib.rs index 3f478012391..9a3286676da 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,5 +20,9 @@ cfg_attr(doc, doc = ::document_features::document_features!()) )] #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] -#![deny(rust_2018_idioms, missing_docs)] +#![deny(rust_2018_idioms)] +#![allow(missing_docs)] #![forbid(unsafe_code)] + +/// everything in common beteween the `gix` and `ein` binaries. +pub mod shared; diff --git a/src/plumbing/main.rs b/src/plumbing/main.rs index 38b6ba261b8..6383bc195bc 100644 --- a/src/plumbing/main.rs +++ b/src/plumbing/main.rs @@ -26,7 +26,7 @@ use crate::{ #[cfg(feature = "gitoxide-core-async-client")] pub mod async_util { - use crate::shared::ProgressRange; + use gitoxide::shared::ProgressRange; #[cfg(not(feature = "prodash-render-line"))] compile_error!("BUG: Need at least a line renderer in async mode"); @@ -39,7 +39,7 @@ pub mod async_util { Option, gix_features::progress::DoOrDiscard, ) { - use crate::shared::{self, STANDARD_RANGE}; + use gitoxide::shared::{self, STANDARD_RANGE}; shared::init_env_logger(); if verbose { diff --git a/src/plumbing/options/free.rs b/src/plumbing/options/free.rs index 9f945c5c640..625204bcf80 100644 --- a/src/plumbing/options/free.rs +++ b/src/plumbing/options/free.rs @@ -39,7 +39,7 @@ pub mod index { #[derive(Debug, clap::Parser)] pub struct Platform { /// The object format to assume when reading files that don't inherently know about it, or when writing files. - #[clap(long, default_value_t = gix::hash::Kind::default(), value_parser = crate::shared::AsHashKind)] + #[clap(long, default_value_t = gix::hash::Kind::default(), value_parser = gitoxide::shared::AsHashKind)] pub object_hash: gix::hash::Kind, /// The path to the index file. diff --git a/src/plumbing/options/mod.rs b/src/plumbing/options/mod.rs index 048bc60a6e9..0ff3c1980d3 100644 --- a/src/plumbing/options/mod.rs +++ b/src/plumbing/options/mod.rs @@ -16,7 +16,7 @@ pub struct Args { /// /// For example, if `key` is `core.abbrev`, set configuration like `[core] abbrev = key`, /// or `remote.origin.url = foo` to set `[remote "origin"] url = foo`. - #[clap(long, short = 'c', value_parser = crate::shared::AsBString)] + #[clap(long, short = 'c', value_parser = gitoxide::shared::AsBString)] pub config: Vec, #[clap(long, short = 't')] @@ -63,12 +63,12 @@ pub struct Args { long, short = 'f', default_value = "human", - value_parser = crate::shared::AsOutputFormat + value_parser = gitoxide::shared::AsOutputFormat )] pub format: core::OutputFormat, /// The object format to assume when reading files that don't inherently know about it, or when writing files. - #[clap(long, default_value_t = gix::hash::Kind::default(), value_parser = crate::shared::AsHashKind)] + #[clap(long, default_value_t = gix::hash::Kind::default(), value_parser = gitoxide::shared::AsHashKind)] pub object_hash: gix::hash::Kind, #[clap(subcommand)] @@ -237,7 +237,7 @@ pub mod config { /// /// Typical filters are `branch` or `remote.origin` or `remote.or*` - git-style globs are supported /// and comparisons are case-insensitive. - #[clap(value_parser = crate::shared::AsBString)] + #[clap(value_parser = gitoxide::shared::AsBString)] pub filter: Vec, } } @@ -276,7 +276,7 @@ pub mod fetch { pub remote: Option, /// Override the built-in and configured ref-specs with one or more of the given ones. - #[clap(value_parser = crate::shared::AsBString)] + #[clap(value_parser = gitoxide::shared::AsBString)] pub ref_spec: Vec, } @@ -291,11 +291,11 @@ pub mod fetch { pub deepen: Option, /// Cutoff all history past the given date. Can be combined with shallow-exclude. - #[clap(long, help_heading = Some("SHALLOW"), value_parser = crate::shared::AsTime, value_name = "DATE", conflicts_with_all = ["depth", "deepen", "unshallow"])] + #[clap(long, help_heading = Some("SHALLOW"), value_parser = gitoxide::shared::AsTime, value_name = "DATE", conflicts_with_all = ["depth", "deepen", "unshallow"])] pub shallow_since: Option, /// Cutoff all history past the tag-name or ref-name. Can be combined with shallow-since. - #[clap(long, help_heading = Some("SHALLOW"), value_parser = crate::shared::AsPartialRefName, value_name = "REF_NAME", conflicts_with_all = ["depth", "deepen", "unshallow"])] + #[clap(long, help_heading = Some("SHALLOW"), value_parser = gitoxide::shared::AsPartialRefName, value_name = "REF_NAME", conflicts_with_all = ["depth", "deepen", "unshallow"])] pub shallow_exclude: Vec, /// Remove the shallow boundary and fetch the entire history available on the remote. @@ -362,11 +362,11 @@ pub mod clone { pub depth: Option, /// Cutoff all history past the given date. Can be combined with shallow-exclude. - #[clap(long, help_heading = Some("SHALLOW"), value_parser = crate::shared::AsTime, value_name = "DATE")] + #[clap(long, help_heading = Some("SHALLOW"), value_parser = gitoxide::shared::AsTime, value_name = "DATE")] pub shallow_since: Option, /// Cutoff all history past the tag-name or ref-name. Can be combined with shallow-since. - #[clap(long, help_heading = Some("SHALLOW"), value_parser = crate::shared::AsPartialRefName, value_name = "REF_NAME")] + #[clap(long, help_heading = Some("SHALLOW"), value_parser = gitoxide::shared::AsPartialRefName, value_name = "REF_NAME")] pub shallow_exclude: Vec, } @@ -418,7 +418,7 @@ pub mod remote { #[clap(long, short = 'u')] show_unmapped_remote_refs: bool, /// Override the built-in and configured ref-specs with one or more of the given ones. - #[clap(value_parser = crate::shared::AsBString)] + #[clap(value_parser = gitoxide::shared::AsBString)] ref_spec: Vec, }, } @@ -594,7 +594,7 @@ pub mod revision { pub mod attributes { use gix::bstr::BString; - use crate::shared::CheckPathSpec; + use gitoxide::shared::CheckPathSpec; #[derive(Debug, clap::Subcommand)] pub enum Subcommands { @@ -625,7 +625,7 @@ pub mod exclude { use gix::bstr::BString; - use crate::shared::CheckPathSpec; + use gitoxide::shared::CheckPathSpec; #[derive(Debug, clap::Subcommand)] pub enum Subcommands { @@ -656,7 +656,7 @@ pub mod index { use gix::bstr::BString; - use crate::shared::CheckPathSpec; + use gitoxide::shared::CheckPathSpec; pub mod entries { #[derive(Default, Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, clap::ValueEnum)] diff --git a/src/porcelain/main.rs b/src/porcelain/main.rs index abd21e1cf67..6f7224e2b98 100644 --- a/src/porcelain/main.rs +++ b/src/porcelain/main.rs @@ -7,10 +7,8 @@ use anyhow::Result; use clap::Parser; use gitoxide_core as core; -use crate::{ - porcelain::options::{Args, Subcommands}, - shared::pretty::prepare_and_run, -}; +use crate::porcelain::options::{Args, Subcommands}; +use gitoxide::shared::pretty::prepare_and_run; pub fn main() -> Result<()> { let args: Args = Args::parse_from(gix::env::args_os()); @@ -39,7 +37,7 @@ pub fn main() -> Result<()> { verbose, progress, progress_keep_open, - crate::shared::STANDARD_RANGE, + gitoxide::shared::STANDARD_RANGE, move |_progress, _out, _err| panic!("something went very wrong"), ), Subcommands::Init { directory } => core::repository::init(directory).map(|_| ()), @@ -59,7 +57,7 @@ pub fn main() -> Result<()> { verbose, progress, progress_keep_open, - crate::shared::STANDARD_RANGE, + gitoxide::shared::STANDARD_RANGE, move |mut progress, out, mut err| { let engine = query::prepare( &repo_dir, @@ -99,7 +97,7 @@ pub fn main() -> Result<()> { verbose, progress, progress_keep_open, - crate::shared::STANDARD_RANGE, + gitoxide::shared::STANDARD_RANGE, move |progress, out, _err| { hours::estimate( &working_dir, @@ -126,7 +124,7 @@ pub fn main() -> Result<()> { verbose, progress, progress_keep_open, - crate::shared::STANDARD_RANGE, + gitoxide::shared::STANDARD_RANGE, move |progress, out, _err| { organize::discover( root.unwrap_or_else(|| [std::path::Component::CurDir].iter().collect()), @@ -150,7 +148,7 @@ pub fn main() -> Result<()> { verbose, progress, progress_keep_open, - crate::shared::STANDARD_RANGE, + gitoxide::shared::STANDARD_RANGE, move |progress, _out, _err| { organize::run( if execute { diff --git a/src/porcelain/options.rs b/src/porcelain/options.rs index 7c583fe4ced..32533ad890f 100644 --- a/src/porcelain/options.rs +++ b/src/porcelain/options.rs @@ -116,7 +116,7 @@ pub mod tools { #[cfg(feature = "gitoxide-core-tools-query")] pub mod query { - use crate::shared::AsPathSpec; + use gitoxide::shared::AsPathSpec; #[derive(Debug, clap::Subcommand)] pub enum Command { @@ -143,7 +143,7 @@ pub mod tools { #[clap(default_value = ".")] pub working_dir: PathBuf, /// The name of the revision as spec, like 'HEAD' or 'main' at which to start iterating the commit graph. - #[clap(default_value("HEAD"), value_parser = crate::shared::AsBString)] + #[clap(default_value("HEAD"), value_parser = gitoxide::shared::AsBString)] pub rev_spec: BString, /// Ignore github bots which match the `[bot]` search string. #[clap(short = 'b', long)] diff --git a/tests/snapshots/panic-behaviour/expected-failure b/tests/snapshots/panic-behaviour/expected-failure index c09ee20e7bb..1dafa93b97b 100644 --- a/tests/snapshots/panic-behaviour/expected-failure +++ b/tests/snapshots/panic-behaviour/expected-failure @@ -1,2 +1,2 @@ -thread 'main' panicked at 'something went very wrong', src/porcelain/main.rs:43:42 +thread 'main' panicked at 'something went very wrong', src/porcelain/main.rs:41:42 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace \ No newline at end of file diff --git a/tests/snapshots/panic-behaviour/expected-failure-in-thread b/tests/snapshots/panic-behaviour/expected-failure-in-thread index 3c81842d3fe..b99a2650670 100644 --- a/tests/snapshots/panic-behaviour/expected-failure-in-thread +++ b/tests/snapshots/panic-behaviour/expected-failure-in-thread @@ -1,3 +1,3 @@ -thread 'main' panicked at 'something went very wrong', src/porcelain/main.rs:43:42 +thread 'main' panicked at 'something went very wrong', src/porcelain/main.rs:41:42 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace  \ No newline at end of file diff --git a/tests/snapshots/panic-behaviour/expected-failure-in-thread-with-progress b/tests/snapshots/panic-behaviour/expected-failure-in-thread-with-progress index c1649532e46..c892c1ea47d 100644 --- a/tests/snapshots/panic-behaviour/expected-failure-in-thread-with-progress +++ b/tests/snapshots/panic-behaviour/expected-failure-in-thread-with-progress @@ -1,3 +1,3 @@ -[?1049h[?25lthread '' panicked at 'something went very wrong', src/porcelain/main.rs:43:42 +[?1049h[?25lthread '' panicked at 'something went very wrong', src/porcelain/main.rs:41:42 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace [?25h[?1049l \ No newline at end of file