-
-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:
gix mailmap verify
command (#366)
- Loading branch information
Showing
4 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
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
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 @@ | ||
use crate::OutputFormat; | ||
use anyhow::{bail, Context}; | ||
use git_repository as git; | ||
use std::io::Write; | ||
use std::path::Path; | ||
|
||
pub const PROGRESS_RANGE: std::ops::RangeInclusive<u8> = 1..=2; | ||
|
||
pub fn verify(path: impl AsRef<Path>, format: OutputFormat, mut out: impl Write) -> anyhow::Result<()> { | ||
if format != OutputFormat::Human { | ||
bail!("Only 'human' format is currently supported"); | ||
} | ||
let path = path.as_ref(); | ||
let buf = std::fs::read(path).with_context(|| format!("Failed to read mailmap file at '{}'", path.display()))?; | ||
let mut err_count = 0; | ||
for err in git::mailmap::parse(&buf).filter_map(Result::err) { | ||
err_count += 1; | ||
writeln!(out, "{}", err)?; | ||
} | ||
if err_count == 0 { | ||
writeln!(out, "{} lines OK", git::mailmap::parse(&buf).count())?; | ||
Ok(()) | ||
} else { | ||
bail!("{} lines in '{}' could not be parsed", err_count, path.display()); | ||
} | ||
} |
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
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