Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Jul 25, 2020
1 parent f932256 commit f66b116
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 27 deletions.
1 change: 0 additions & 1 deletion gitoxide-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,3 @@ impl FromStr for OutputFormat {

pub mod pack;
pub mod repository;
pub mod verify;
12 changes: 0 additions & 12 deletions gitoxide-core/src/pack.rs

This file was deleted.

10 changes: 10 additions & 0 deletions gitoxide-core/src/pack/explode.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use anyhow::Result;
use git_features::progress::Progress;
use std::path::Path;

pub fn pack_or_pack_index<P>(_path: impl AsRef<Path>, _progress: Option<P>, _delete_pack: bool) -> Result<()>
where
P: Progress,
{
Ok(())
}
2 changes: 2 additions & 0 deletions gitoxide-core/src/pack/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub mod explode;
pub mod verify;
File renamed without changes.
15 changes: 8 additions & 7 deletions src/plumbing/lean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ mod options {
/// the algorithm used to verify the pack. They differ in costs.
///
/// Possible values are "less-time" and "less-memory". Default is "less-memory".
pub algorithm: Option<core::verify::Algorithm>,
pub algorithm: Option<core::pack::verify::Algorithm>,

/// output statistical information about the pack
#[argh(switch, short = 's')]
Expand Down Expand Up @@ -116,6 +116,7 @@ fn prepare(verbose: bool, name: &str) -> (Option<prodash::line::JoinHandle>, Opt
}

pub fn main() -> Result<()> {
use gitoxide_core::pack::verify;
pub use options::*;
let cli: Args = crate::shared::from_env();
let thread_limit = cli.threads;
Expand All @@ -137,21 +138,21 @@ pub fn main() -> Result<()> {
re_encode,
}) => {
let (_handle, progress) = prepare(verbose, "pack-verify");
core::verify::pack_or_pack_index(
verify::pack_or_pack_index(
path,
progress,
core::verify::Context {
verify::Context {
output_statistics: if statistics {
Some(core::OutputFormat::Human)
} else {
None
},
algorithm: algorithm.unwrap_or(core::verify::Algorithm::LessTime),
algorithm: algorithm.unwrap_or(verify::Algorithm::LessTime),
thread_limit,
mode: match (decode, re_encode) {
(true, false) => core::verify::Mode::Sha1CRC32Decode,
(true, true) | (false, true) => core::verify::Mode::Sha1CRC32DecodeEncode,
(false, false) => core::verify::Mode::Sha1CRC32,
(true, false) => verify::Mode::Sha1CRC32Decode,
(true, true) | (false, true) => verify::Mode::Sha1CRC32DecodeEncode,
(false, false) => verify::Mode::Sha1CRC32,
},
out: stdout(),
err: stderr(),
Expand Down
15 changes: 8 additions & 7 deletions src/plumbing/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use gitoxide_core as core;
use std::io::{stderr, stdout, Write};
use structopt::StructOpt;

use gitoxide_core::pack::verify;
use options::*;

mod options {
Expand Down Expand Up @@ -71,9 +72,9 @@ mod options {
long,
short = "a",
default_value = "less-time",
possible_values(core::verify::Algorithm::variants())
possible_values(core::pack::verify::Algorithm::variants())
)]
algorithm: core::verify::Algorithm,
algorithm: core::pack::verify::Algorithm,

/// Display verbose messages and progress information
#[structopt(long, short = "v")]
Expand Down Expand Up @@ -235,15 +236,15 @@ pub fn main() -> Result<()> {
progress_keep_open,
move |progress, out, err| {
let mode = match (decode, re_encode) {
(true, false) => core::verify::Mode::Sha1CRC32Decode,
(true, true) | (false, true) => core::verify::Mode::Sha1CRC32DecodeEncode,
(false, false) => core::verify::Mode::Sha1CRC32,
(true, false) => verify::Mode::Sha1CRC32Decode,
(true, true) | (false, true) => verify::Mode::Sha1CRC32DecodeEncode,
(false, false) => verify::Mode::Sha1CRC32,
};
let output_statistics = if statistics { Some(format) } else { None };
core::verify::pack_or_pack_index(
verify::pack_or_pack_index(
path,
progress,
core::verify::Context {
verify::Context {
output_statistics,
thread_limit,
algorithm,
Expand Down

0 comments on commit f66b116

Please sign in to comment.