Skip to content

Commit

Permalink
refactor!: Remove light* features, add 'lean-async' in its place; rem…
Browse files Browse the repository at this point in the history
…ove termion support (#215)
  • Loading branch information
Byron committed Dec 5, 2021
1 parent 2abba9c commit 4d2d433
Show file tree
Hide file tree
Showing 27 changed files with 212 additions and 96 deletions.
21 changes: 11 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ doctest = false
[features]
default = ["max"]

max = ["fast", "pretty-cli", "prodash/render-tui-crossterm", "prodash-render-line-crossterm", "prodash/render-line-autoconfigure", "http-client-curl", "gitoxide-core-tools", "gitoxide-core-blocking-client"]
max = ["fast", "pretty-cli", "http-client-curl", "gitoxide-core-tools", "gitoxide-core-blocking-client",
"prodash-render-line", "prodash-render-tui",
"prodash/render-line-autoconfigure" ]

lean = ["fast", "pretty-cli", "prodash-render-line-crossterm", "prodash/progress-tree", "http-client-curl", "gitoxide-core-tools", "gitoxide-core-blocking-client"]
lean-async = ["fast", "pretty-cli", "prodash-render-line-crossterm", "prodash/progress-tree", "http-client-curl", "gitoxide-core-tools", "gitoxide-core-async-client"]
lean = ["fast", "pretty-cli", "http-client-curl", "gitoxide-core-tools", "gitoxide-core-blocking-client",
"prodash-render-line" ]
lean-async = ["fast", "pretty-cli", "gitoxide-core-tools", "gitoxide-core-async-client",
"prodash-render-line"]

small = ["pretty-cli", "git-features/rustsha1", "git-features/zlib-rust-backend"]
small = ["pretty-cli", "git-features/rustsha1", "git-features/zlib-rust-backend", "prodash/progress-log", "atty"]

gitoxide-core-tools = ["gitoxide-core/organize", "gitoxide-core/estimate-hours"]
gitoxide-core-blocking-client = ["gitoxide-core/blocking-client"]
Expand All @@ -45,17 +49,14 @@ pretty-cli = ["clap",
"prodash/progress-tree",
"prodash/progress-tree-log",
"prodash/local-time",
"prodash-render-tui",
"prodash-render-line",
"gitoxide-core/local-time-support",
"env_logger",
"futures-lite"]
"env_logger" ]

prodash-render-line-crossterm = ["prodash-render-line", "prodash/render-line-crossterm", "atty", "crosstermion"]

# internal
prodash-render-tui = ["prodash/render-tui"]
prodash-render-line = ["prodash/render-line"]
prodash-render-tui = ["prodash/render-tui", "prodash/render-tui-crossterm", "prodash/progress-tree", "futures-lite"]
prodash-render-line = ["prodash/render-line", "prodash-render-line-crossterm", "prodash/progress-tree"]
cache-efficiency-debug = ["git-features/cache-efficiency-debug"]

[dependencies]
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ doc: ## Run cargo doc on all crates
clippy: ## Run cargo clippy on all crates
cargo clippy --all --tests
cargo clippy --all --no-default-features --features small
cargo clippy --all --no-default-features --features light-async --tests
cargo clippy --all --no-default-features --features lean-async --tests

check: ## Build all code in suitable configurations
cargo check --all
Expand Down Expand Up @@ -156,17 +156,17 @@ jtt = target/debug/jtt
journey-tests: always ## run journey tests (max)
cargo build
cargo build --package git-testtools --bin jtt
./tests/journey.sh target/debug/gix target/debug/gix $(jtt) max
./tests/journey.sh target/debug/ein target/debug/gix $(jtt) max

journey-tests-small: always ## run journey tests (lean-cli)
cargo build --no-default-features --features small
cd tests/tools && cargo build
./tests/journey.sh target/debug/gix target/debug/gix $(jtt) small
./tests/journey.sh target/debug/ein target/debug/gix $(jtt) small

journey-tests-async: always ## run journey tests (light-async)
cargo build --no-default-features --features light-async
journey-tests-async: always ## run journey tests (lean-async)
cargo build --no-default-features --features lean-async
cd tests/tools && cargo build
./tests/journey.sh target/debug/gix target/debug/gix $(jtt) async
./tests/journey.sh target/debug/ein target/debug/gix $(jtt) async

journey-tests-smart-release:
cargo build --package cargo-smart-release
Expand Down
2 changes: 1 addition & 1 deletion cargo-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ There are **convenience features**, which combine common choices of the above in
* Due to async client-networking not being implemented for most transports, this one supports only the 'git' transport. It uses, however, a fully asynchronous
networking implementation which can serve a real-world example on how to implement custom async transports.
* **small**
* As small as it can possibly be, no threading, no fast sha1, log based progress only, no cleanup of temporary files on interrupt, rust based zlib implementation.
* As small as it can possibly be, no threading, no fast sha1, log based progress only, rust based zlib implementation.
* no networking, local operations only.

### gitoxide-core
Expand Down
2 changes: 1 addition & 1 deletion gitoxide-core/src/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub mod refs {
#[cfg(feature = "serde1")]
OutputFormat::Json => serde_json::to_writer_pretty(
ctx.out,
&delegate.refs.into_iter().map(JsonRef::from).collect::<Vec<_>>(),
&delegate.refs.into_iter().map(super::JsonRef::from).collect::<Vec<_>>(),
)?,
}
Ok(())
Expand Down
27 changes: 19 additions & 8 deletions src/plumbing/pretty/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,25 @@ use crate::{
};

pub fn main() -> Result<()> {
let Args {
threads: thread_limit,
verbose,
progress,
progress_keep_open,
format,
cmd,
} = Args::parse();
let args: Args = Args::parse();
let thread_limit = args.threads;
let verbose = args.verbose;
let format = args.format;
let cmd = args.cmd;

let progress;
let progress_keep_open;
#[cfg(feature = "prodash-render-tui")]
{
progress = args.progress;
progress_keep_open = args.progress_keep_open;
}
#[cfg(not(feature = "prodash-render-tui"))]
{
progress = false;
progress_keep_open = false;
}

let should_interrupt = Arc::new(AtomicBool::new(false));
git_repository::interrupt::init_handler({
let should_interrupt = Arc::clone(&should_interrupt);
Expand Down
2 changes: 2 additions & 0 deletions src/plumbing/pretty/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ pub struct Args {
pub verbose: bool,

/// Bring up a terminal user interface displaying progress visually
#[cfg(feature = "prodash-render-tui")]
#[clap(long, conflicts_with("verbose"))]
pub progress: bool,

/// The progress TUI will stay up even though the work is already completed.
///
/// Use this to be able to read progress messages or additional information visible in the TUI log pane.
#[cfg(feature = "prodash-render-tui")]
#[clap(long, conflicts_with("verbose"), requires("progress"))]
pub progress_keep_open: bool,

Expand Down
19 changes: 8 additions & 11 deletions src/porcelain/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@ use std::sync::{

use anyhow::Result;
use clap::Parser;
use git_features::progress::DoOrDiscard;
use gitoxide_core as core;

use crate::{
porcelain::options::{Args, EstimateHours, Subcommands, ToolCommands},
shared::pretty::prepare_and_run,
};
use crate::{porcelain::options::Args, porcelain::options::Subcommands, shared::pretty::prepare_and_run};

pub fn main() -> Result<()> {
let args: Args = Args::parse();
Expand All @@ -35,8 +31,9 @@ pub fn main() -> Result<()> {
move |_progress, _out, _err| panic!("something went very wrong"),
),
Subcommands::Init { directory } => core::repository::init(directory).map(|_| ()),
#[cfg(feature = "gitoxide-core-tools")]
Subcommands::Tools(tool) => match tool {
ToolCommands::EstimateHours(EstimateHours {
crate::porcelain::options::ToolCommands::EstimateHours(crate::porcelain::options::EstimateHours {
working_dir,
refname,
show_pii,
Expand All @@ -53,7 +50,7 @@ pub fn main() -> Result<()> {
hours::estimate(
&working_dir,
&refname,
DoOrDiscard::from(progress),
git_features::progress::DoOrDiscard::from(progress),
hours::Context {
show_pii,
omit_unify_identities,
Expand All @@ -63,7 +60,7 @@ pub fn main() -> Result<()> {
},
)
}
ToolCommands::Find { root } => {
crate::porcelain::options::ToolCommands::Find { root } => {
use gitoxide_core::organize;
prepare_and_run(
"find",
Expand All @@ -75,12 +72,12 @@ pub fn main() -> Result<()> {
organize::discover(
root.unwrap_or_else(|| [std::path::Component::CurDir].iter().collect()),
out,
DoOrDiscard::from(progress),
git_features::progress::DoOrDiscard::from(progress),
)
},
)
}
ToolCommands::Organize {
crate::porcelain::options::ToolCommands::Organize {
destination_directory,
execute,
repository_source,
Expand All @@ -101,7 +98,7 @@ pub fn main() -> Result<()> {
},
repository_source.unwrap_or_else(|| [std::path::Component::CurDir].iter().collect()),
destination_directory.unwrap_or_else(|| [std::path::Component::CurDir].iter().collect()),
DoOrDiscard::from(progress),
git_features::progress::DoOrDiscard::from(progress),
)
},
)
Expand Down
2 changes: 2 additions & 0 deletions src/porcelain/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ pub enum Subcommands {
/// Defaults to the current working directory.
directory: Option<PathBuf>,
},
#[cfg(feature = "gitoxide-core-tools")]
/// A selection of useful tools
#[clap(subcommand)]
Tools(ToolCommands),
#[cfg(debug_assertions)]
Panic,
}

#[cfg(feature = "gitoxide-core-tools")]
#[derive(Debug, clap::Parser)]
#[clap(setting = AppSettings::DisableVersionFlag, setting = AppSettings::SubcommandRequired)]
#[clap(visible_alias = "t")]
Expand Down

0 comments on commit 4d2d433

Please sign in to comment.