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