st3-gitblame
st3-gitblame copied to clipboard
Formatting when author name contains brackets
-
Sublime Text version:
- 4123
-
How did you install this package?:
- Manually downloaded
-
Operating System and version:
- macOS 12.6
-
How did you install git itself?
- already came with my OS
Hi,
if the author name contains brackets, the regex matching fails. Say, the authorname is Lastname, Firstname (External)
parsing the git blame output
# With bracket
line = "SHA Filename (Lastname, Firstname (External) 2022-10-13 16:30:25 +0200 16)\n"
m = parse_line(line)
d = postprocess_parse_result(m)
for x in d:
print("{:14s} : {:4s}".format(x, d[x]))
gives
sha : SHA
file : Filename (Lastname, Firstname
author : External)
date : 2022-10-13
time : 16:30:25
timezone : +0200
line_number : 16
sha_normalised : SHA
I get correct results if I replace \s+ (?P<file>[\S ]+)
with \s+ (?P<file>[\S]+)
(remove the whitespace behind \S) in the parse_line
function, but not sure if this will break for different examples.
Thank you for the report. I think I can fix this by making the file part of the regex non-greedy, i.e. ending with +?
instead of +
. I will add another unit test based on your example.
That would be perfect, thx!