summaryrefslogtreecommitdiffstats
path: root/src/parse.rs
diff options
context:
space:
mode:
authorDan Davison <dandavison7@gmail.com>2020-07-05 22:16:02 -0400
committerDan Davison <dandavison7@gmail.com>2020-07-05 22:16:29 -0400
commit6a94050a9fb9123668edc1bbe371af20dea62d2a (patch)
tree6fde9589a927737763c970238e5692ea33f47f02 /src/parse.rs
parent6dc82b46270e2de75d181f26167d29a1b5f6de93 (diff)
Refactor: reformat regex
Diffstat (limited to 'src/parse.rs')
-rw-r--r--src/parse.rs19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/parse.rs b/src/parse.rs
index c2f4b0ad..006e7464 100644
--- a/src/parse.rs
+++ b/src/parse.rs
@@ -90,8 +90,23 @@ pub fn get_file_change_description_from_file_paths(
}
lazy_static! {
- static ref HUNK_METADATA_REGEXP: Regex =
- Regex::new(r"@+ (?P<lns>([-+]\d+(?:,\d+)? ){2,4})@+(?P<cf>.*\s?)").unwrap();
+ static ref HUNK_METADATA_REGEXP: Regex = Regex::new(
+ r"(?x)
+@+ # Start hunk header
+\ # One space
+(?P<lns> # Start file coordinates
+ ( # Start file coordinate
+ [-+] # - or +
+ \d+ # A digit
+ (?:,\d+)? # Optionally followed by a comma and another digit
+ \ # One space
+ ){2,4} #
+) #
+@+ # End hunk header
+(?P<cf>.*\s?) # Code fragment
+"
+ )
+ .unwrap();
}
lazy_static! {