Skip to content

wrong name/email parsing when email is empty #833

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

Closed
ghost opened this issue Jan 23, 2019 · 2 comments
Closed

wrong name/email parsing when email is empty #833

ghost opened this issue Jan 23, 2019 · 2 comments

Comments

@ghost
Copy link

ghost commented Jan 23, 2019

in file:

https://github.com/gitpython-developers/GitPython/blob/master/git/util.py

line 537 and 538


name_only_regex = re.compile(r'<(.+)>')
name_email_regex = re.compile(r'(.*) <(.+?)>')

since the email regexp ask for one or more characters non-greedy, the regexp will grab

"name <>"
as
name="name <>" email=None

the problem is that the right parse is name="name" email=""

which made my data pipeline produce wrong results, changing those two lines for


name_only_regex = re.compile(r'<(.*)>')
name_email_regex = re.compile(r'(.*) <(.*?)>')

that fixes the problem

for those like me who need something working right now, a workaround is to use git natively
author_name = os.popen(f"cd '{path}'; git --no-pager show -s --format='%aN' {sha1}").read()[0:-1]
author_email = os.popen(f"cd '{path}'; git --no-pager show -s --format='%aE' {sha1}").read()[0:-1]
commit_name = os.popen(f"cd '{path}'; git --no-pager show -s --format='%cN' {sha1}").read()[0:-1]
commit_email = os.popen(f"cd '{path}'; git --no-pager show -s --format='%cE' {sha1}").read()[0:-1]

@ghost ghost closed this as completed in c282315 Jul 6, 2019
@Byron Byron added this to the v2.1.12 - Bugfixes milestone Jul 6, 2019
@Byron
Copy link
Member

Byron commented Jul 6, 2019

Thanks a lot for the description of the issue, and the fix. I have made the respective changes.

@ghost
Copy link
Author

ghost commented Jul 8, 2019

thanks to you!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant