Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for collecting and recording per-file metadata #63

Merged
merged 17 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 56 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions crates/noseyparker-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ vergen = { version = "8.1", features = ["build", "cargo", "git", "gitcl", "rustc
anyhow = { version = "1.0" }
clap = { version = "4.3", features = ["cargo", "derive", "env", "unicode", "wrap_help"] }
console = "0.15"
gix-features = "0.30"
gix = { version = "0.46", features = ["max-performance"] }
hex = "0.4"
crossbeam-channel = "0.5"
indenter = "0.3"
# XXX Consider switching from indicatif to status_line: https://docs.rs/status-line/latest/status_line/struct.StatusLine.html
indicatif = { version = "0.17", features = ["improved_unicode", "rayon"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/noseyparker-cli/src/bin/noseyparker/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ impl GlobalArgs {
match self.color {
Mode::Never => false,
Mode::Always => true,
Mode::Auto => std::io::stdin().is_terminal(),
Mode::Auto => std::io::stdout().is_terminal(),
}
}

Expand Down
15 changes: 4 additions & 11 deletions crates/noseyparker-cli/src/bin/noseyparker/cmd_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::fmt::{Display, Formatter, Write};

use noseyparker::bstring_escape::Escaped;
use noseyparker::datastore::{Datastore, MatchGroupMetadata};
use noseyparker::digest::sha1_hexdigest;
use noseyparker::match_type::Match;
use noseyparker::provenance::Provenance;

Expand Down Expand Up @@ -123,13 +124,9 @@ impl Reportable for DetailsReporter {
let source_span = &m.location.source_span;
// let offset_span = &m.location.offset_span;
let uri = match m.provenance {
Provenance::File { path } => {
path.display().to_string()
}
Provenance::File { path } => path.display().to_string(),
// FIXME: using this path is nonsense here
Provenance::GitRepo { path } => {
path.display().to_string()
}
Provenance::GitRepo { path } => path.display().to_string(),
};

let location = sarif::LocationBuilder::default()
Expand Down Expand Up @@ -170,11 +167,7 @@ impl Reportable for DetailsReporter {
})
.collect::<Result<_>>()?;

let sha1_fingerprint = {
let mut h = gix_features::hash::Sha1::default();
h.update(&metadata.match_content);
hex::encode(h.digest())
};
let sha1_fingerprint = sha1_hexdigest(&metadata.match_content);

// Build the result for the match
let result = sarif::ResultBuilder::default()
Expand Down
Loading