Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting when author name contains brackets #72

Open
preiter93 opened this issue Oct 16, 2022 · 2 comments
Open

Formatting when author name contains brackets #72

preiter93 opened this issue Oct 16, 2022 · 2 comments
Assignees

Comments

@preiter93
Copy link

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

@frou
Copy link
Owner

frou commented Oct 17, 2022

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.

@preiter93
Copy link
Author

That would be perfect, thx!

@frou frou self-assigned this Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants