Updated regex to check single line and added test case
This commit is contained in:
parent
485dc7bf95
commit
b8af08b40a
@ -19,7 +19,7 @@ NOT_MAIN_BRANCH = Exception('Not merging into a main branch')
|
|||||||
NO_GIT_FLOW = Exception('No git flow branch found')
|
NO_GIT_FLOW = Exception('No git flow branch found')
|
||||||
|
|
||||||
# Important regex
|
# 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):
|
class SemVer(object):
|
||||||
|
|
||||||
|
@ -139,6 +139,13 @@ class TestGetCommitMessageRegex(unittest.TestCase):
|
|||||||
self.assertEqual(matches.group(2), "branch")
|
self.assertEqual(matches.group(2), "branch")
|
||||||
else:
|
else:
|
||||||
self.assertTrue(False)
|
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):
|
def test_non_merge_message(self):
|
||||||
matches = GET_COMMIT_MESSAGE.search("Example unrelated commit message that should get 0 matches")
|
matches = GET_COMMIT_MESSAGE.search("Example unrelated commit message that should get 0 matches")
|
||||||
self.assertEqual(matches, None)
|
self.assertEqual(matches, None)
|
||||||
|
Loading…
Reference in New Issue
Block a user