From 4d2df638d141ff4f970c92171bd35091798f9872 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Mon, 5 Feb 2018 11:05:13 -0600 Subject: [PATCH] Use item.checkout from zuul.projects when mirroring We need to set the remote HEAD of the repos after we mirror them. We have been doing that by looking at git status on the local repos to find what their head has been set to. However, we have 'checkout' in zuul.projects now, so we can really just use that. Change-Id: I251da11b7767793278c3f08dcf64aa008e759669 Depends-On: https://review.openstack.org/540948 --- .../tasks/main.yaml | 33 +------------------ 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/roles/mirror-workspace-git-repos/tasks/main.yaml b/roles/mirror-workspace-git-repos/tasks/main.yaml index 9c7a171c2..dc01fd9a8 100644 --- a/roles/mirror-workspace-git-repos/tasks/main.yaml +++ b/roles/mirror-workspace-git-repos/tasks/main.yaml @@ -17,37 +17,6 @@ tags: - skip_ansible_lint -- name: Show git status of src repos in workspace - # Show the full git status output for each repo to debug failures - # when determining HEAD in the next task. - shell: "echo '{{ item.key }}:'; git status" - args: - chdir: "{{ zuul.executor.work_root }}/{{ item.value.src_dir }}" - with_dict: "{{ zuul.projects }}" - delegate_to: localhost - # ANSIBLE0006: Skip linting since it triggers on the "git" command, - # but status is not supported by ansible git module. - tags: - - skip_ansible_lint - -- name: Determine local HEAD of projects - # Output yaml-valid dict data for projects and their current HEAD - shell: "echo '{{ item.key }}:' $(git status | head -1 |awk '{ print $NF }')" - args: - chdir: "{{ zuul.executor.work_root }}/{{ item.value.src_dir }}" - with_dict: "{{ zuul.projects }}" - delegate_to: localhost - register: project_heads_yaml - # ANSIBLE0006: Skip linting since it triggers on the "git" command, - # but status is not supported by ansible git module. - tags: - - skip_ansible_lint - -- name: Build dict to map project and current head HEAD - set_fact: - project_heads: "{{ project_heads|default({}) | combine( item.stdout | from_yaml ) }}" - with_items: '{{ project_heads_yaml.results }}' - # Do this as a multi-line shell so that we can do the loop once - name: Update remote repository state correctly shell: | @@ -56,7 +25,7 @@ # Undo the config setting we did above git config --local --unset receive.denyCurrentBranch # checkout the branch matching the branch set up by the executor - git checkout {{ project_heads[item.key] }} + git checkout {{ item.value.checkout }} args: chdir: "{{ ansible_user_dir }}/{{ item.value.src_dir }}" with_dict: "{{ zuul.projects }}"