st3-gitblame icon indicating copy to clipboard operation
st3-gitblame copied to clipboard

Formatting when author name contains brackets

Open preiter93 opened this issue 1 year ago • 2 comments

  • 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.

preiter93 avatar Oct 16 '22 08:10 preiter93

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.

frou avatar Oct 17 '22 10:10 frou

That would be perfect, thx!

preiter93 avatar Oct 17 '22 14:10 preiter93