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

Fix submodule diff parsing #1413

Merged
merged 1 commit into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion src/handlers/submodule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl<'a> StateMachine<'a> {

lazy_static! {
static ref SUBMODULE_SHORT_LINE_REGEX: Regex =
Regex::new("^[-+]Subproject commit ([0-9a-f]{40})$").unwrap();
Regex::new("^[-+]Subproject commit ([0-9a-f]{40})(-dirty)?$").unwrap();
}

pub fn get_submodule_short_commit(line: &str) -> Option<&str> {
Expand Down
24 changes: 24 additions & 0 deletions src/tests/test_example_diffs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,20 @@ mod tests {
assert_eq!(strip_ansi_codes(&output), DIFF_WITH_MERGE_CONFLICT);
}

#[test]
fn test_simple_dirty_submodule_diff() {
DeltaTest::with_args(&["--width", "30"])
.with_input(SUBMODULE_DIRTY)
.inspect()
.expect_after_skip(
1,
r#"
some_submodule
──────────────────────────────
ca030fd..803be42"#,
);
}

#[test]
fn test_submodule_diff_log() {
// See etc/examples/662-submodules
Expand Down Expand Up @@ -1934,6 +1948,16 @@ This is a regular file that contains:
Some text here
-Some text with a minus
+Some text with a plus
";

const SUBMODULE_DIRTY: &str = "\
diff --git a/some_submodule b/some_submodule
index ca030fd1a0..803be42ca4 160000
--- a/some_submodule
+++ b/some_submodule
@@ -1 +1 @@
-Subproject commit ca030fd1a02225a6fc1a834c480276d9c97a8c6f
+Subproject commit 803be42ca46af0fbc65b54a9abfb499389516939-dirty
";

// See etc/examples/662-submodules
Expand Down