From 8003cdc76ca177061b1a462d07efaff83e18491b Mon Sep 17 00:00:00 2001 From: bernhardbergpartner Date: Tue, 30 Apr 2024 09:27:02 +0200 Subject: [PATCH] prepare-workspace-git: Add allow deleting current branch In cases where the HEAD branch of a repository is deleted, prepare-workspace-git will be unable to propagate that deletion from the executor repos to a clone of a cached repo on a remote node. Correct this by unsetting the receive.delyDeleteCurrent flag. This was correctly set in mirror-workspace-git, but did not make it into prepare-workspace-git. Change-Id: I159fb1f9f9cee873466f11be2f155bed6892472e --- roles/prepare-workspace-git/tasks/main.yaml | 15 +++++---------- roles/test-prepare-workspace-git/tasks/main.yaml | 15 +++++---------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/roles/prepare-workspace-git/tasks/main.yaml b/roles/prepare-workspace-git/tasks/main.yaml index 644ae412d..51f554f02 100644 --- a/roles/prepare-workspace-git/tasks/main.yaml +++ b/roles/prepare-workspace-git/tasks/main.yaml @@ -30,6 +30,10 @@ fi cd {{ zuul_workspace_root }}/{{ zj_project.src_dir }} git config --local --bool core.bare false + # Allow pushing to non-bare repo + git config --local receive.denyCurrentBranch ignore + # Allow deleting current branch + git config --local receive.denyDeleteCurrent ignore git remote -v | grep origin && git remote rm origin || true git remote add origin file:///dev/null args: @@ -42,16 +46,6 @@ tags: - skip_ansible_lint -- name: Allow pushing to non-bare repo - git_config: - name: receive.denyCurrentBranch - value: ignore - scope: local - repo: "{{ zuul_workspace_root }}/{{ zj_project.value.src_dir }}" - with_dict: "{{ _zuul_projects }}" - loop_control: - loop_var: zj_project - - name: Include tasks to synchronize src repos to workspace directory include_tasks: sync-project.yaml with_dict: "{{ _zuul_projects }}" @@ -69,6 +63,7 @@ git clean -xdf # Undo the config setting we did above git config --local --unset receive.denyCurrentBranch + git config --local --unset receive.denyDeleteCurrent # checkout the branch matching the branch set up by the executor git checkout {% if mirror_workspace_quiet %}--quiet{% endif %} {{ zj_project.value.checkout }} # put out a status line with the current HEAD diff --git a/roles/test-prepare-workspace-git/tasks/main.yaml b/roles/test-prepare-workspace-git/tasks/main.yaml index 5e68daf99..3787b53ac 100644 --- a/roles/test-prepare-workspace-git/tasks/main.yaml +++ b/roles/test-prepare-workspace-git/tasks/main.yaml @@ -30,6 +30,10 @@ fi cd {{ zuul_workspace_root }}/{{ zj_project.src_dir }} git config --local --bool core.bare false + # Allow pushing to non-bare repo + git config --local receive.denyCurrentBranch ignore + # Allow deleting current branch + git config --local receive.denyDeleteCurrent ignore git remote -v | grep origin && git remote rm origin || true git remote add origin file:///dev/null args: @@ -42,16 +46,6 @@ tags: - skip_ansible_lint -- name: Allow pushing to non-bare repo - git_config: - name: receive.denyCurrentBranch - value: ignore - scope: local - repo: "{{ zuul_workspace_root }}/{{ zj_project.value.src_dir }}" - with_dict: "{{ _zuul_projects }}" - loop_control: - loop_var: zj_project - - name: Synchronize src repos to workspace directory command: |- {% if ansible_connection == "kubectl" %} @@ -90,6 +84,7 @@ git clean -xdf # Undo the config setting we did above git config --local --unset receive.denyCurrentBranch + git config --local --unset receive.denyDeleteCurrent # checkout the branch matching the branch set up by the executor git checkout {% if mirror_workspace_quiet %}--quiet{% endif %} {{ zj_project.value.checkout }} # put out a status line with the current HEAD