Update regex check to look at merged branch

This commit is contained in:
Layla 2019-12-13 16:51:05 -05:00
parent c6d25a0e55
commit e434a82ccb

View File

@ -64,25 +64,24 @@ class SemVer(object):
def get_version_type(self):
print('Merged branch is ' + self.merged_branch)
#Get GitHub repo's owner from url
repoOwner = None
remoteUrl = subprocess.Popen(['git', 'config', '--get', 'remote.origin.url'], stdout=subprocess.PIPE).stdout.read().decode('utf-8').rstrip()
if "github.com" in remoteUrl:
repoOwner = re.search("(?<=github.com(:|\/))(.*)(?=\/.*.git)", remoteUrl).group(0)
merged_prefix = None
matches = re.findall("[\/][^\/]+[\/]", self.merged_branch)
if len(matches > 1):
merged_prefix = matches[1][1:-1]
for prefix in self.major_branches:
if self.merged_branch.startswith(prefix + '/') or self.merged_branch.startswith(str(repoOwner) + '/' + prefix + '/'):
self.version_type = 'major'
return True
for prefix in self.minor_branches:
if self.merged_branch.startswith(prefix + '/') or self.merged_branch.startswith(str(repoOwner) + '/' + prefix + '/'):
self.version_type = 'minor'
return True
for prefix in self.patch_branches:
if self.merged_branch.startswith(prefix + '/') or self.merged_branch.startswith(str(repoOwner) + '/' + prefix + '/'):
self.version_type = 'patch'
return True
if merged_prefix:
for prefix in self.major_branches:
if prefix == merged_prefix:
self.version_type = 'major'
return True
for prefix in self.minor_branches:
if prefix == merged_prefix:
self.version_type = 'minor'
return True
for prefix in self.patch_branches:
if prefix == merged_prefix:
self.version_type = 'patch'
return True
return False
# setup git settings so we can commit and tag