Merge "Allow default-branch in our projects.yaml checking"

This commit is contained in:
Zuul 2022-02-03 20:32:58 +00:00 committed by Gerrit Code Review
commit 6223e9a8b5

View File

@ -34,7 +34,7 @@ def tempdir():
shutil.rmtree(reqroot, ignore_errors=True) shutil.rmtree(reqroot, ignore_errors=True)
def check_repo(repo_path): def check_repo(repo_path, default_branch):
found_errors = 0 found_errors = 0
print("Checking git repo '%s':" % repo_path) print("Checking git repo '%s':" % repo_path)
@ -45,11 +45,11 @@ def check_repo(repo_path):
print(" Remote branches:") print(" Remote branches:")
for r in branches: for r in branches:
print(" %s" % r) print(" %s" % r)
if 'origin/master' in branches: if 'origin/%s' % default_branch in branches:
print(" Master branch exists.") print(" %s branch exists." % default_branch)
else: else:
found_errors += 1 found_errors += 1
print(" ERROR: No master branch exists") print(" ERROR: No %s branch exists" % default_branch)
if 'origin/stable' in branches: if 'origin/stable' in branches:
found_errors += 1 found_errors += 1
print(" ERROR: A branch named 'stable' exists, this will" print(" ERROR: A branch named 'stable' exists, this will"
@ -160,7 +160,8 @@ def main():
VALID_LABELS = ["acl-config", "description", "docimpact-group", VALID_LABELS = ["acl-config", "description", "docimpact-group",
"groups", "homepage", "options", "project", "groups", "homepage", "options", "project",
"upstream", "use-storyboard", "cgit-alias"] "upstream", "use-storyboard", "cgit-alias",
"default-branch"]
VALID_SCHEMES = ['https://', 'http://', 'git://'] VALID_SCHEMES = ['https://', 'http://', 'git://']
DESCRIPTION_REQUIRED = ['openstack', 'openstack-infra', 'openstack-dev', DESCRIPTION_REQUIRED = ['openstack', 'openstack-infra', 'openstack-dev',
'stackforge'] 'stackforge']
@ -215,15 +216,16 @@ def main():
# but not git@ # but not git@
upstream = p.get('upstream') upstream = p.get('upstream')
if upstream: if upstream:
default_branch = p.get('default-branch', 'master')
openstack_repo = 'https://opendev.org/%s' % name openstack_repo = 'https://opendev.org/%s' % name
try: try:
# Check to see if we have already imported the project into # Check to see if we have already imported the project into
# OpenStack, if so skip checking upstream. # OpenStack, if so skip checking upstream.
check_repo(openstack_repo) check_repo(openstack_repo, default_branch)
except git.exc.GitCommandError: except git.exc.GitCommandError:
# We haven't imported the repo yet, make sure upstream is # We haven't imported the repo yet, make sure upstream is
# valid. # valid.
found_errors += check_repo(upstream) found_errors += check_repo(upstream, default_branch)
for prefix in VALID_SCHEMES: for prefix in VALID_SCHEMES:
if upstream.startswith(prefix): if upstream.startswith(prefix):
break break