From d447f7d2dfda7c7a379efdf16e37ae3967bdd12e Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Tue, 5 Mar 2019 19:38:31 +0000 Subject: [PATCH] Revert "Revert "Set default branch for repo"" This reverts commit b076aefa0864dc12269a4454a921f4830b2a2d9a. This may still not work. The last time it got 404s when running as part of project creation. So possibly it was failing because there was no git content yet and thus master was an invalid value. If that's the case, we may need to add auto_init to true just to get a default repo and metadata and count on gerrit force-pushing during first replication. Use auto_init to create a repo with a master branch It's not possible to set the default_branch to master if there is no repo, and without that first replication sets the branch incorrectly. Set auto_init to true to get an empty repo which will be replaced by the initial gerrit force-push anyway. Change-Id: I66de43a4d00583c06cf92bb7083ce28d4b8d4df9 Story: 2004627 Task: 29847 --- .../roles/gitea-git-repos/tasks/setup-repo.yaml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/playbooks/roles/gitea-git-repos/tasks/setup-repo.yaml b/playbooks/roles/gitea-git-repos/tasks/setup-repo.yaml index fdeb65dbbb..fd9a4812cb 100644 --- a/playbooks/roles/gitea-git-repos/tasks/setup-repo.yaml +++ b/playbooks/roles/gitea-git-repos/tasks/setup-repo.yaml @@ -17,7 +17,7 @@ method: POST body_format: json body: - auto_init: false + auto_init: true description: "{{ (project.description | default(''))[:255] }}" name: "{{ repo }}" private: false @@ -46,3 +46,18 @@ external_tracker_url: "https://storyboard.openstack.org/#!/project/{{ org }}/{{ repo }}" tracker_url_format: https://storyboard.openstack.org/#!/story/{index} tracker_issue_style: numeric +- name: Set default branch + when: gitea_always_update or project.project not in gitea_repos + uri: + url: "{{ gitea_url }}/{{ org }}/{{ repo }}/settings/branches" + validate_certs: false + user: root + password: "{{ gitea_root_password }}" + force_basic_auth: true + status_code: 302 + method: POST + body_format: form-urlencoded + body: + _csrf: "{{ gitea_token }}" + action: default_branch + branch: master