Testing regex

This commit is contained in:
2020-02-28 16:56:50 +00:00
parent 7040fbb1a0
commit cb05f46aa6
2 changed files with 26 additions and 4 deletions

View File

@ -18,9 +18,11 @@ NO_MERGE_FOUND = Exception('No merge found')
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) (?:'(.+)'|[^\/]+\/(.+))")
class SemVer(object):
GET_COMMIT_MESSAGE = re.compile(r"Merge (branch|pull request) '?(.+)'? (into|from) (?:'(.+)'|[^\/]+\/(.+))")
# Merge pull request #1 from RightBrain-Networks/feature/PLAT-185-versioning
def __init__(self,global_user=False):
@ -52,7 +54,7 @@ class SemVer(object):
message = str(p.stdout.read())
branch = b.stdout.read().decode('utf-8').rstrip()
logger.info('Main branch is ' + branch)
matches = self.GET_COMMIT_MESSAGE.search(message)
matches = GET_COMMIT_MESSAGE.search(message)
if matches:
if str(matches.group(4)) == branch:
self.merged_branch = matches.group(2)