diff options
author | Dan Davison <dandavison7@gmail.com> | 2021-08-23 00:24:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-23 00:24:49 -0700 |
commit | bffa1efded7359b57d862a25422ef6b386ff9e4c (patch) | |
tree | 6bd5e5f1f0819a0c5df789d155a19fb17f49c8bb /src/parse.rs | |
parent | 5e02d340a8b3f3184f84a34434d7ad170988331f (diff) |
More minimalistic display of submodule (short) diffs (#700)
* Rename state machine state: Submodule -> SubmoduleLog
* More minimalistic display of submodule log diffs
Partially fixes #662
* Defer emitting hunk header until first true hunk line
A consequence is that we do not emit the (pseudo) hunk header in
submodule (short) state; see #662.
Diffstat (limited to 'src/parse.rs')
-rw-r--r-- | src/parse.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/parse.rs b/src/parse.rs index a62d486c..c6a0860f 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -268,6 +268,18 @@ fn get_extension(s: &str) -> Option<&str> { .or_else(|| path.file_name().and_then(|s| s.to_str())) } +lazy_static! { + static ref SUBMODULE_SHORT_LINE_REGEX: Regex = + Regex::new("^[-+]Subproject commit ([0-9a-f]{40})$").unwrap(); +} + +pub fn get_submodule_short_commit(line: &str) -> Option<&str> { + match SUBMODULE_SHORT_LINE_REGEX.captures(line) { + Some(caps) => Some(caps.get(1).unwrap().as_str()), + None => None, + } +} + #[cfg(test)] mod tests { use super::*; |