Skip to content

Commit d15159d

Browse files
committed
Merge pull request #3 from jopereira/master
Git index revision ids might have more that 7 characters.
2 parents ac751d1 + 1b456f0 commit d15159d

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
diff --git a/bugtrace/patch.py b/bugtrace/patch.py
2+
index 18910dfd..2456e34f 100644
3+
--- a/bugtrace/patch.py
4+
+++ b/bugtrace/patch.py
5+
@@ -8,20 +8,30 @@
6+

tests/test_patch.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,23 @@ def test_git_header(self):
603603
results_main = wtp.patch.parse_header(text)
604604
self.assertEqual(results_main, expected)
605605

606+
def test_git_header_long(self):
607+
with open('tests/casefiles/git-header-long.diff') as f:
608+
text = f.read()
609+
610+
expected = wtp.patch.header(
611+
index_path = None,
612+
old_path = 'bugtrace/patch.py',
613+
old_version = '18910dfd',
614+
new_path = 'bugtrace/patch.py',
615+
new_version = '2456e34f')
616+
617+
results = wtp.patch.parse_git_header(text)
618+
self.assertEqual(results, expected)
619+
620+
results_main = wtp.patch.parse_header(text)
621+
self.assertEqual(results_main, expected)
622+
606623
def test_svn_header(self):
607624
with open('tests/casefiles/svn-header.diff') as f:
608625
text = f.read()

whatthepatch/patch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
# git has a special index header and no end part
4343
git_diffcmd_header = re.compile('^diff --git a/(.+) b/(.+)$')
44-
git_header_index = re.compile('^index ([\w]{7})..([\w]{7}) ?(\d*)$')
44+
git_header_index = re.compile('^index ([a-f0-9]+)..([a-f0-9]+) ?(\d*)$')
4545
git_header_old_line = re.compile('^--- (.+)$')
4646
git_header_new_line = re.compile('^\+\+\+ (.+)$')
4747
git_header_file_mode = re.compile('^(new|deleted) file mode \d{6}$')

0 commit comments

Comments
 (0)