Skip to content

Commit c2cf554

Browse files
committed
Altenative unified 0 diff output for a single-line addition.
NO_JIRA
1 parent 50f495e commit c2cf554

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

main/githooks.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,10 @@ def parse_diff_header(header_line):
173173
start = int(match.group(1))
174174
if match.group(2):
175175
num = int(match.group(3))
176-
changed_lines = f'{start}-{start+num-1}'
176+
if num > 0:
177+
changed_lines = f'{start}-{start+num-1}'
178+
else:
179+
changed_lines = str(start)
177180
else:
178181
changed_lines = str(start)
179182
return changed_lines
@@ -187,6 +190,8 @@ def _test(input, output):
187190
_test('@@ -142 +178 @@', '178')
188191
_test('@@ -142 +178,3 @@', '178-180')
189192
_test('@@ -142 +178,7 @@', '178-184')
193+
_test('@@ -3,0 +3 @@', '3')
194+
_test('@@ -1 +0,0 @@', '0')
190195

191196

192197
def get_changed_lines(modified_file):

0 commit comments

Comments
 (0)