diff options
author | Dan Davison <dandavison7@gmail.com> | 2019-07-21 19:58:41 -0400 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2019-07-21 20:03:58 -0400 |
commit | c1cd649d64f58e95287a228dcf736c0d81243c95 (patch) | |
tree | d32af48aa454b0764562c14f590ea2db4945f109 /src/parse.rs | |
parent | f127cd4cfc74d03d8156805a7c3e580fe46b74f1 (diff) |
For a rename, use the new extension to infer language
Diffstat (limited to 'src/parse.rs')
-rw-r--r-- | src/parse.rs | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/parse.rs b/src/parse.rs index 90ece066..76328aa7 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -5,13 +5,9 @@ use std::path::Path; /// Return "rs", i.e. a single file extension consistent with both files. pub fn get_file_extension_from_diff_line(line: &str) -> Option<&str> { match get_file_extensions_from_diff_line(line) { - (Some(ext1), Some(ext2)) => { - if ext1 == ext2 { - Some(ext1) - } else { - // Unexpected: old and new files have different extensions. - None - } + (Some(_ext1), Some(ext2)) => { + // If they differ then it's a rename; use the new extension. + Some(ext2) } (Some(ext1), None) => Some(ext1), (None, Some(ext2)) => Some(ext2), |