From 6058d994b8bd36a8cf46b14ae2f05f806b895191 Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Wed, 15 Jul 2020 09:20:28 -0700 Subject: [PATCH] Add branches arg to createProject This new functiona argument will allow callers to set the default project branch on repo creation. It takes a list, all branches will be created with the first being repo HEAD. Change-Id: Iae5a71662740678e663bcd73d6ac660559db5d9a --- .zuul.yaml | 1 + gerritlib/gerrit.py | 6 +++++- playbooks/jeepyb-integration/pre.yaml | 3 +++ tools/projects.yaml | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 playbooks/jeepyb-integration/pre.yaml diff --git a/.zuul.yaml b/.zuul.yaml index 5e2f19e..19cbe5e 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -1,6 +1,7 @@ - job: name: gerritlib-jeepyb-integration description: Run manage_projects with gerritlib from source against Gerrit + pre-run: playbooks/jeepyb-integration/pre.yaml run: playbooks/jeepyb-integration/run.yaml post-run: playbooks/jeepyb-integration/post.yaml required-projects: diff --git a/gerritlib/gerrit.py b/gerritlib/gerrit.py index d34cc2c..6172488 100644 --- a/gerritlib/gerrit.py +++ b/gerritlib/gerrit.py @@ -257,7 +257,7 @@ class Gerrit(object): self._setMember('remove', group, member) def createProject(self, project, require_change_id=True, empty_repo=False, - description=None): + description=None, branches=None): cmd = 'gerrit create-project' if require_change_id: cmd = '%s --require-change-id' % cmd @@ -266,6 +266,10 @@ class Gerrit(object): if description: cmd = "%s --description \"%s\"" % \ (cmd, description.replace('"', r'\"')) + if branches: + # Branches should be a list. The first entry will be repo HEAD. + for branch in branches: + cmd = "%s --branch \"%s\"" % (cmd, branch) version = None try: version = self.parseGerritVersion(self.getVersion()) diff --git a/playbooks/jeepyb-integration/pre.yaml b/playbooks/jeepyb-integration/pre.yaml new file mode 100644 index 0000000..76ff177 --- /dev/null +++ b/playbooks/jeepyb-integration/pre.yaml @@ -0,0 +1,3 @@ +- hosts: all + roles: + - name: ensure-pip diff --git a/tools/projects.yaml b/tools/projects.yaml index 7d5028d..b0f2ef7 100644 --- a/tools/projects.yaml +++ b/tools/projects.yaml @@ -10,6 +10,7 @@ acl-config: tools/acls/test/test.config groups: - testing + default-branch: main - project: test/test-repo-3 description: A retired repo acl-config: tools/acls/test/retired.config