From 81e58b7893078cca3ac4de1bcf8d1ac6252c9bd2 Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Thu, 3 Feb 2022 10:36:38 -0800 Subject: [PATCH] Allow default-branch in our projects.yaml checking Some projects may not be created with a master branch and choose to use a different default-branch value. There is support for this in jeepyb and our gitea git repo management role but we don't allow it in linting. Update our linting to accomodate projects making this change. Change-Id: I57ef2c10d2c29142801ba134c8183bb0393771a8 --- tools/check_valid_gerrit_projects.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tools/check_valid_gerrit_projects.py b/tools/check_valid_gerrit_projects.py index 154ed316f1..4ff290ecf4 100755 --- a/tools/check_valid_gerrit_projects.py +++ b/tools/check_valid_gerrit_projects.py @@ -34,7 +34,7 @@ def tempdir(): shutil.rmtree(reqroot, ignore_errors=True) -def check_repo(repo_path): +def check_repo(repo_path, default_branch): found_errors = 0 print("Checking git repo '%s':" % repo_path) @@ -45,11 +45,11 @@ def check_repo(repo_path): print(" Remote branches:") for r in branches: print(" %s" % r) - if 'origin/master' in branches: - print(" Master branch exists.") + if 'origin/%s' % default_branch in branches: + print(" %s branch exists." % default_branch) else: found_errors += 1 - print(" ERROR: No master branch exists") + print(" ERROR: No %s branch exists" % default_branch) if 'origin/stable' in branches: found_errors += 1 print(" ERROR: A branch named 'stable' exists, this will" @@ -160,7 +160,8 @@ def main(): VALID_LABELS = ["acl-config", "description", "docimpact-group", "groups", "homepage", "options", "project", - "upstream", "use-storyboard", "cgit-alias"] + "upstream", "use-storyboard", "cgit-alias", + "default-branch"] VALID_SCHEMES = ['https://', 'http://', 'git://'] DESCRIPTION_REQUIRED = ['openstack', 'openstack-infra', 'openstack-dev', 'stackforge'] @@ -215,15 +216,16 @@ def main(): # but not git@ upstream = p.get('upstream') if upstream: + default_branch = p.get('default-branch', 'master') openstack_repo = 'https://opendev.org/%s' % name try: # Check to see if we have already imported the project into # OpenStack, if so skip checking upstream. - check_repo(openstack_repo) + check_repo(openstack_repo, default_branch) except git.exc.GitCommandError: # We haven't imported the repo yet, make sure upstream is # valid. - found_errors += check_repo(upstream) + found_errors += check_repo(upstream, default_branch) for prefix in VALID_SCHEMES: if upstream.startswith(prefix): break