Skip to content

Commit

Permalink
fix build (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Apr 28, 2022
1 parent 61ea4c4 commit cb56f12
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 12 deletions.
1 change: 1 addition & 0 deletions git-repository/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::head;
pub struct Worktree<'repo> {
pub(crate) parent: &'repo Repository,
/// The root path of the checkout.
#[allow(dead_code)]
pub(crate) path: &'repo std::path::Path,
}

Expand Down
4 changes: 2 additions & 2 deletions gitoxide-core/src/repository/exclude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ pub mod query {

pub fn query(
repo: git::Repository,
out: impl io::Write,
query::Options { format, pathspecs }: query::Options,
_out: impl io::Write,
query::Options { format, pathspecs: _ }: query::Options,
) -> anyhow::Result<()> {
if format != OutputFormat::Human {
bail!("JSON output isn't implemented yet");
Expand Down
27 changes: 18 additions & 9 deletions src/plumbing/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ pub fn main() -> Result<()> {
},
Subcommands::Repository(repo::Platform { repository, cmd }) => {
use git_repository as git;
let repository = git::open(repository)?.apply_environment();
let repository = git::ThreadSafeRepository::open(repository)?;
match cmd {
repo::Subcommands::Commit { cmd } => match cmd {
repo::commit::Subcommands::Describe {
Expand All @@ -177,7 +177,7 @@ pub fn main() -> Result<()> {
None,
move |_progress, out, err| {
core::repository::commit::describe(
repository,
repository.into(),
rev_spec.as_deref(),
out,
err,
Expand All @@ -203,7 +203,7 @@ pub fn main() -> Result<()> {
None,
move |_progress, out, _err| {
core::repository::exclude::query(
repository,
repository.into(),
out,
core::repository::exclude::query::Options { format, pathspecs },
)
Expand All @@ -217,7 +217,9 @@ pub fn main() -> Result<()> {
progress,
progress_keep_open,
None,
move |_progress, out, err| core::repository::mailmap::entries(repository, format, out, err),
move |_progress, out, err| {
core::repository::mailmap::entries(repository.into(), format, out, err)
},
),
},
repo::Subcommands::Odb { cmd } => match cmd {
Expand All @@ -227,15 +229,15 @@ pub fn main() -> Result<()> {
progress,
progress_keep_open,
None,
move |_progress, out, _err| core::repository::odb::entries(repository, format, out),
move |_progress, out, _err| core::repository::odb::entries(repository.into(), format, out),
),
repo::odb::Subcommands::Info => prepare_and_run(
"repository-odb-info",
verbose,
progress,
progress_keep_open,
None,
move |_progress, out, err| core::repository::odb::info(repository, format, out, err),
move |_progress, out, err| core::repository::odb::info(repository.into(), format, out, err),
),
},
repo::Subcommands::Tree { cmd } => match cmd {
Expand All @@ -251,7 +253,7 @@ pub fn main() -> Result<()> {
None,
move |_progress, out, _err| {
core::repository::tree::entries(
repository,
repository.into(),
treeish.as_deref(),
recursive,
extended,
Expand All @@ -267,7 +269,14 @@ pub fn main() -> Result<()> {
progress_keep_open,
None,
move |_progress, out, err| {
core::repository::tree::info(repository, treeish.as_deref(), extended, format, out, err)
core::repository::tree::info(
repository.into(),
treeish.as_deref(),
extended,
format,
out,
err,
)
},
),
},
Expand All @@ -287,7 +296,7 @@ pub fn main() -> Result<()> {
core::repository::verify::PROGRESS_RANGE,
move |progress, out, _err| {
core::repository::verify::integrity(
repository,
repository.into(),
out,
progress,
&should_interrupt,
Expand Down
46 changes: 45 additions & 1 deletion src/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,56 @@ pub mod pretty {

use crate::shared::ProgressRange;

#[cfg(feature = "small")]
pub fn prepare_and_run<T>(
name: &str,
verbose: bool,
progress: bool,
#[cfg_attr(not(feature = "prodash-render-tui"), allow(unused_variables))] progress_keep_open: bool,
range: impl Into<Option<ProgressRange>>,
run: impl FnOnce(
progress::DoOrDiscard<prodash::tree::Item>,
&mut dyn std::io::Write,
&mut dyn std::io::Write,
) -> Result<T>,
) -> Result<T> {
crate::shared::init_env_logger();

match (verbose, progress) {
(false, false) => {
let stdout = stdout();
let mut stdout_lock = stdout.lock();
let stderr = stderr();
let mut stderr_lock = stderr.lock();
run(progress::DoOrDiscard::from(None), &mut stdout_lock, &mut stderr_lock)
}
(true, false) => {
let progress = crate::shared::progress_tree();
let sub_progress = progress.add_child(name);

use crate::shared::{self, STANDARD_RANGE};
let handle = shared::setup_line_renderer_range(&progress, range.into().unwrap_or(STANDARD_RANGE));

let mut out = Vec::<u8>::new();
let res = run(progress::DoOrDiscard::from(Some(sub_progress)), &mut out, &mut stderr());
handle.shutdown_and_wait();
std::io::Write::write_all(&mut stdout(), &out)?;
res
}
#[cfg(not(feature = "prodash-render-tui"))]
(true, true) | (false, true) => {
unreachable!("BUG: This branch can't be run without a TUI built-in")
}
}
}

#[cfg(not(feature = "small"))]
pub fn prepare_and_run<T: Send + 'static>(
name: &str,
verbose: bool,
progress: bool,
#[cfg_attr(not(feature = "prodash-render-tui"), allow(unused_variables))] progress_keep_open: bool,
#[cfg_attr(not(feature = "prodash-render-line"), allow(unused_variables))] range: impl Into<Option<ProgressRange>>,
range: impl Into<Option<ProgressRange>>,
run: impl FnOnce(
progress::DoOrDiscard<prodash::tree::Item>,
&mut dyn std::io::Write,
Expand Down

0 comments on commit cb56f12

Please sign in to comment.