-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Merge pull request #33 from TanmayPatil105/context-diff-modification-…
…time Display modification times of input files in context and unified diff
Showing
9 changed files
with
306 additions
and
34 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
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
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,25 @@ | ||
// asserts equality of the actual diff and expected diff | ||
// considering datetime varitations | ||
// | ||
// It replaces the modification time in the actual diff | ||
// with placeholer "TIMESTAMP" and then asserts the equality | ||
// | ||
// For eg. | ||
// let brief = "*** fruits_old.txt\t2024-03-24 23:43:05.189597645 +0530\n | ||
// --- fruits_new.txt\t2024-03-24 23:35:08.922581904 +0530\n"; | ||
// | ||
// replaced = "*** fruits_old.txt\tTIMESTAMP\n | ||
// --- fruits_new.txt\tTIMESTAMP\n"; | ||
#[macro_export] | ||
macro_rules! assert_diff_eq { | ||
($actual:expr, $expected:expr) => {{ | ||
use regex::Regex; | ||
use std::str; | ||
|
||
let diff = str::from_utf8(&$actual).unwrap(); | ||
let re = Regex::new(r"\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ [+-]\d{4}").unwrap(); | ||
let actual = re.replacen(diff, 2, "TIMESTAMP"); | ||
|
||
assert_eq!(actual, $expected); | ||
}}; | ||
} |
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
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