From 51fe46231f7b7b67d90713c8eff2736ad7ead4fc Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Tue, 23 Jul 2024 17:19:26 -0700 Subject: [PATCH] Make prepare-workspace-git behavior more consistent This runs the same commands on the git repo regardless of whether it was cloned or if the role found it there already. Since the purpose of the role is to mirror the workspace repos from the executor to the remote node, this will produce more consistent behavior. Note that anyone somehow relying on, say, the origin being set outside of this role may encounter a behavior change. It is expected that anyone manipulating a repo that is also managed by this role would perform those manipulations idempotently after running this role. Change-Id: I428bf2980a526919d5b154c585943be92d4c1cfa --- roles/prepare-workspace-git/tasks/main.yaml | 6 +++--- roles/test-prepare-workspace-git/tasks/main.yaml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/roles/prepare-workspace-git/tasks/main.yaml b/roles/prepare-workspace-git/tasks/main.yaml index 8c4b18c5c..726cf4727 100644 --- a/roles/prepare-workspace-git/tasks/main.yaml +++ b/roles/prepare-workspace-git/tasks/main.yaml @@ -30,15 +30,15 @@ git init {{ zuul_workspace_root }}/{{ zj_project.src_dir }} fi cd {{ zuul_workspace_root }}/{{ zj_project.src_dir }} - git config --local --bool core.bare false - git remote -v | grep origin && git remote rm origin || true - git remote add origin file:///dev/null 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 with_items: "{{ _zuul_projects.values() }}" loop_control: loop_var: zj_project diff --git a/roles/test-prepare-workspace-git/tasks/main.yaml b/roles/test-prepare-workspace-git/tasks/main.yaml index 8c4b18c5c..726cf4727 100644 --- a/roles/test-prepare-workspace-git/tasks/main.yaml +++ b/roles/test-prepare-workspace-git/tasks/main.yaml @@ -30,15 +30,15 @@ git init {{ zuul_workspace_root }}/{{ zj_project.src_dir }} fi cd {{ zuul_workspace_root }}/{{ zj_project.src_dir }} - git config --local --bool core.bare false - git remote -v | grep origin && git remote rm origin || true - git remote add origin file:///dev/null 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 with_items: "{{ _zuul_projects.values() }}" loop_control: loop_var: zj_project