forked from crev-dev/cargo-crev
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
89 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,6 @@ members = [ | |
"crev-bin", | ||
"cargo-crev", | ||
"recursive-digest", | ||
"rblake2sum" | ||
"rblake2sum", | ||
"crevsum" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[package] | ||
name = "crevsum" | ||
version = "0.1.0" | ||
authors = ["Dawid Ciężarkiewicz <dpc@dpc.pw>"] | ||
edition = "2018" | ||
description = "Recursive digest as calculated by `crev`" | ||
keywords = ["data", "filesystem", "digest", "hash"] | ||
license = "MPL-2.0 OR MIT OR Apache-2.0" | ||
documentation = "https://docs.rs/rblake2sum" | ||
homepage = "https://github.com/dpc/crev/tree/master/rblake2sum" | ||
repository = "https://github.com/dpc/crev/tree/master/rblake2sum" | ||
readme = "README.md" | ||
|
||
[dependencies] | ||
base64 = "0.9.0" | ||
|
||
hex = "0.3" | ||
crev-recursive-digest = { path = "../recursive-digest", version = "0.1" } | ||
structopt = "0.2" | ||
common_failures = "0.1" | ||
failure = "0.1" | ||
|
||
|
||
[dependencies.crev-common] | ||
path = "../crev-common" | ||
version = "0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# `rblake2sum` | ||
|
||
Calculate a recursive digest of paths, using [`crev-recursive-digest`](https://github.com/dpc/crev/tree/master/recursive-digest) algorithm. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
merge_imports = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
extern crate structopt; | ||
|
||
mod opts; | ||
|
||
use common_failures::prelude::*; | ||
use structopt::StructOpt; | ||
|
||
use std::collections::HashSet; | ||
|
||
fn main() -> Result<()> { | ||
let opts = opts::Opts::from_args(); | ||
|
||
for path in opts.paths { | ||
let digest = crev_recursive_digest::get_recursive_digest_for_dir::< | ||
crev_common::Blake2b256, | ||
_, | ||
>(&path, &HashSet::new())?; | ||
println!( | ||
"{} {}", | ||
if opts.base64 { | ||
crev_common::base64_encode(&digest) | ||
} else { | ||
hex::encode(digest) | ||
}, | ||
path.display() | ||
); | ||
} | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use std::path::PathBuf; | ||
use structopt::StructOpt; | ||
|
||
#[derive(Debug, StructOpt, Clone)] | ||
#[structopt( | ||
name = "rblake2sum", | ||
about = "Calculate recursive blake2 digest for path or directory" | ||
)] | ||
pub struct Opts { | ||
#[structopt(long = "base64")] | ||
pub base64: bool, | ||
#[structopt(parse(from_os_str))] | ||
pub paths: Vec<PathBuf>, | ||
} |