From 1e2a34704a9232f3b16c659dbea58d35bdc8f3f4 Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Wed, 15 Jul 2020 08:59:18 -0700 Subject: [PATCH] Allow setting Gitea repo branch on project creation Note this shouldn't be used until we can configure Gerrit to do similar with jeepyb. Otherwise we'll end up with mismatched branches between our canonical source (Gerrit) and our mirrors (Gitea). Change-Id: I8d353cbc90c2d354e7cdebfc4e247f3f73d97d86 --- .../library/gitea_create_repos.py | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/playbooks/roles/gitea-git-repos/library/gitea_create_repos.py b/playbooks/roles/gitea-git-repos/library/gitea_create_repos.py index a0afec63fd..be0dcb0038 100755 --- a/playbooks/roles/gitea-git-repos/library/gitea_create_repos.py +++ b/playbooks/roles/gitea-git-repos/library/gitea_create_repos.py @@ -122,14 +122,23 @@ class Gitea(object): def make_gitea_project(self, project, csrf_token): org, repo = project['project'].split('/', 1) + repo_properties = { + 'auto_init': True, + 'name': repo, + 'description': project.get('description', '')[:255], + # Do not use this functionality until jeepyb can do similar + # for the gerrit side. Once Gerrit and Gitea can be configured + # this could be used on new repos. + # Note we default to master to avoid relying on tool defaults + # as we currently rely on Gitea, Gerrit, and Git to all be in + # sync which may not be the case going forward. + 'default_branch': project.get('default-branch', 'master'), + 'private': False, + 'readme': 'Default', + } resp = self.post( '/api/v1/org/{org}/repos'.format(org=org), - json=dict( - auto_init=True, - description=project.get('description', '')[:255], - name=repo, - private=False, - readme='Default')) + json=repo_properties) self.log("Created repo:", project['project']) def update_gitea_project_settings(self, project, csrf_token):