1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-17 00:07:37 +02:00

Fix git log parsing with empty name or email

Sometimes, folks leave their name or email blank in on their
git commits.  Previously, a blank name crashed the git log
parser.
This commit is contained in:
Adam Wolf
2022-11-11 13:33:01 -06:00
parent 299b0faf7c
commit e4cdfa13ca
7 changed files with 72 additions and 12 deletions

View File

@ -63,6 +63,9 @@ class MyTests(unittest.TestCase):
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-is-hash-regex-fix.out'), 'r', encoding='utf-8') as f:
git_log_fuller_is_hash_regex_fix = f.read()
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-blank-author-fix.out'), 'r', encoding='utf-8') as f:
git_log_blank_author_fix = f.read()
# output
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log.json'), 'r', encoding='utf-8') as f:
git_log_json = json.loads(f.read())
@ -118,6 +121,9 @@ class MyTests(unittest.TestCase):
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-is-hash-regex-fix.json'), 'r', encoding='utf-8') as f:
git_log_fuller_is_hash_regex_fix_json = json.loads(f.read())
with open(os.path.join(THIS_DIR, os.pardir, 'tests/fixtures/generic/git-log-blank-author-fix.json'), 'r', encoding='utf-8') as f:
git_log_blank_author_fix_json = json.loads(f.read())
def test_git_log_nodata(self):
"""
@ -235,6 +241,13 @@ class MyTests(unittest.TestCase):
"""
self.assertEqual(jc.parsers.git_log.parse(self.git_log_fuller_is_hash_regex_fix, quiet=True), self.git_log_fuller_is_hash_regex_fix_json)
def test_git_log_blank_author_fix(self):
"""
Test 'git_log' fix for when a commit author has a blank name,
empty email, or both
"""
self.assertEqual(jc.parsers.git_log.parse(self.git_log_blank_author_fix, quiet=True), self.git_log_blank_author_fix_json)
if __name__ == '__main__':
unittest.main()