Merge pull request #47 from RightBrain-Networks/bugfix/regexNewLines

BUGFIX: Fixed versioning with branch name commit description
This commit is contained in:
Derek DeJonghe 2020-06-16 12:39:32 -04:00 committed by GitHub
commit 2664efea0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -19,7 +19,7 @@ NOT_MAIN_BRANCH = Exception('Not merging into a main branch')
NO_GIT_FLOW = Exception('No git flow branch found')
# Important regex
GET_COMMIT_MESSAGE = re.compile(r"Merge (branch|pull request) '?([^']+)'? (into|from) (?:'(.+)'|[^\/]+\/(.+))")
GET_COMMIT_MESSAGE = re.compile(r"Merge (branch|pull request) '?([^']+)'? (into|from) (?:'(.+)'|[^\/]+\/([^\n\\]+))")
class SemVer(object):

View File

@ -139,6 +139,13 @@ class TestGetCommitMessageRegex(unittest.TestCase):
self.assertEqual(matches.group(2), "branch")
else:
self.assertTrue(False)
def test_branch_in_message(self):
matches = GET_COMMIT_MESSAGE.search(str(b'commit examplehash\nMerge: example\nAuthor: Test <test@nodomain.rightbrainnetworks.com>\nDate: Mon Jun 15 18:15:22 2020 -0400\n\n Merge pull request #45 from user/branch\n \n user/branch\n'))
if matches:
self.assertEqual(matches.group(4), None)
self.assertEqual(matches.group(5), "branch")
else:
self.assertTrue(False)
def test_non_merge_message(self):
matches = GET_COMMIT_MESSAGE.search("Example unrelated commit message that should get 0 matches")
self.assertEqual(matches, None)