Skip to content

Commit 0786340

Browse files
committed
Properly accommodate multi-line header line entries.
1 parent cf58b9c commit 0786340

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

gitstage.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
to the headers and do not contain changes to the translation strings.
55
"""
66

7-
# Copyright (C) 2023 Bob Swift
7+
# Copyright (C) 2023-2024 Bob Swift
88

99

1010
import argparse
@@ -18,8 +18,8 @@
1818

1919

2020
SCRIPT_NAME = 'Picard Docs Git File Stager'
21-
SCRIPT_VERS = '0.4'
22-
SCRIPT_INITIAL_COPYRIGHT = '2023'
21+
SCRIPT_VERS = '0.5'
22+
SCRIPT_INITIAL_COPYRIGHT = '2024'
2323
SCRIPT_INITIAL_AUTHOR = 'Bob Swift'
2424

2525
DEFAULT_COMPARISON_DISPLAY_LEVEL = 'changed'
@@ -287,7 +287,12 @@ def process_change(files_to_stage: dict, fullfilename: str, minus: str, plus: st
287287
if minus != plus:
288288
files_to_stage[fullfilename] = 'Modified'
289289

290-
for line in git_diff:
290+
line_count = len(git_diff)
291+
line_num = 0
292+
while line_num < line_count:
293+
line = git_diff[line_num]
294+
line_num += 1
295+
# for line in git_diff:
291296
# Ignore nearby lines and unchanged ranges
292297
if line and line[0] in {' ', '@'}:
293298
continue
@@ -338,6 +343,10 @@ def process_change(files_to_stage: dict, fullfilename: str, minus: str, plus: st
338343
if re.match(r'[+-].*\\n"$', line) or re.match(r'[+-]"(' + HEADER_KEYS_TO_IGNORE + r')', line, re.IGNORECASE):
339344
process_change(files_to_stage, fullfilename, minus, plus)
340345
minus = plus = last = ''
346+
# Keep skipping lines until header line ends with '\n"'
347+
while line_num < line_count and not re.match(r'[+-].*\\n"$', line.strip()):
348+
line = git_diff[line_num]
349+
line_num += 1
341350
continue
342351

343352
# Add files with changed translation text lines

0 commit comments

Comments
 (0)