Merge pull request #27 from RightBrain-Networks/feature/openSourceSupport

Open Source Workflow Support
This commit is contained in:
Derek DeJonghe 2019-12-16 15:41:47 -05:00 committed by GitHub
commit 4ca295b541
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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