Skip to content

Commit

Permalink
Properly accommodate multi-line header line entries.
Browse files Browse the repository at this point in the history
  • Loading branch information
rdswift committed Mar 24, 2024
1 parent cf58b9c commit 0786340
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions gitstage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
to the headers and do not contain changes to the translation strings.
"""

# Copyright (C) 2023 Bob Swift
# Copyright (C) 2023-2024 Bob Swift


import argparse
Expand All @@ -18,8 +18,8 @@


SCRIPT_NAME = 'Picard Docs Git File Stager'
SCRIPT_VERS = '0.4'
SCRIPT_INITIAL_COPYRIGHT = '2023'
SCRIPT_VERS = '0.5'
SCRIPT_INITIAL_COPYRIGHT = '2024'
SCRIPT_INITIAL_AUTHOR = 'Bob Swift'

DEFAULT_COMPARISON_DISPLAY_LEVEL = 'changed'
Expand Down Expand Up @@ -287,7 +287,12 @@ def process_change(files_to_stage: dict, fullfilename: str, minus: str, plus: st
if minus != plus:
files_to_stage[fullfilename] = 'Modified'

for line in git_diff:
line_count = len(git_diff)
line_num = 0
while line_num < line_count:
line = git_diff[line_num]
line_num += 1
# for line in git_diff:
# Ignore nearby lines and unchanged ranges
if line and line[0] in {' ', '@'}:
continue
Expand Down Expand Up @@ -338,6 +343,10 @@ def process_change(files_to_stage: dict, fullfilename: str, minus: str, plus: st
if re.match(r'[+-].*\\n"$', line) or re.match(r'[+-]"(' + HEADER_KEYS_TO_IGNORE + r')', line, re.IGNORECASE):
process_change(files_to_stage, fullfilename, minus, plus)
minus = plus = last = ''
# Keep skipping lines until header line ends with '\n"'
while line_num < line_count and not re.match(r'[+-].*\\n"$', line.strip()):
line = git_diff[line_num]
line_num += 1
continue

# Add files with changed translation text lines
Expand Down

0 comments on commit 0786340

Please sign in to comment.