diff --git a/test/integration/targets/git/tasks/setup-local-repos.yml b/test/integration/targets/git/tasks/setup-local-repos.yml index 4626f1028bf..3723f4dda4c 100644 --- a/test/integration/targets/git/tasks/setup-local-repos.yml +++ b/test/integration/targets/git/tasks/setup-local-repos.yml @@ -56,6 +56,16 @@ args: chdir: "{{ repo_dir }}/shallow_branches" +- name: SETUP-LOCAL-REPOS | get ref head for test_branch + shell: git checkout test_branch && git rev-parse HEAD + args: + chdir: "{{ repo_dir }}/shallow_branches" + register: ref_head_id + +- name: SETUP-LOCAL-REPOS | store ref head for test_branch + set_fact: + test_branch_ref_head_id: "{{ ref_head_id.stdout }}" + # Make this a bare one, we need to be able to push to it from clones # We make the repo here for consistency with the other repos, # but we finish setting it up in forcefully-fetch-tag.yml. diff --git a/test/integration/targets/git/tasks/specific-revision.yml b/test/integration/targets/git/tasks/specific-revision.yml index f1fe41d5626..ffb0a4ed51f 100644 --- a/test/integration/targets/git/tasks/specific-revision.yml +++ b/test/integration/targets/git/tasks/specific-revision.yml @@ -70,11 +70,11 @@ # Same as the previous test, but this time we specify which ref # contains the SHA1 - name: SPECIFIC-REVISION | update to revision by specifying the refspec - git: - repo: https://github.com/ansible/ansible-examples.git + git: &git_ref_spec + repo: "{{ repo_dir }}/shallow_branches/.git" dest: '{{ checkout_dir }}' - version: 5473e343e33255f2da0b160f53135c56921d875c - refspec: refs/pull/7/merge + version: "{{ test_branch_ref_head_id }}" + refspec: refs/heads/test_branch - name: SPECIFIC-REVISION | check HEAD after update with refspec command: git rev-parse HEAD @@ -84,7 +84,7 @@ - assert: that: - - 'git_result.stdout == "5473e343e33255f2da0b160f53135c56921d875c"' + - 'git_result.stdout == test_branch_ref_head_id' # try out combination of refspec and depth - name: SPECIFIC-REVISION | clear checkout_dir @@ -94,11 +94,8 @@ - name: SPECIFIC-REVISION | update to revision by specifying the refspec with depth=1 git: - repo: https://github.com/ansible/ansible-examples.git - dest: '{{ checkout_dir }}' - version: 5473e343e33255f2da0b160f53135c56921d875c - refspec: refs/pull/7/merge depth: 1 + <<: *git_ref_spec - name: SPECIFIC-REVISION | check HEAD after update with refspec command: git rev-parse HEAD @@ -108,7 +105,7 @@ - assert: that: - - 'git_result.stdout == "5473e343e33255f2da0b160f53135c56921d875c"' + - 'git_result.stdout == test_branch_ref_head_id' - name: SPECIFIC-REVISION | try to access other commit shell: git checkout 0ce1096 @@ -130,11 +127,7 @@ path: "{{ checkout_dir }}" - name: SPECIFIC-REVISION | clone to revision by specifying the refspec - git: - repo: https://github.com/ansible/ansible-examples.git - dest: "{{ checkout_dir }}" - version: 5473e343e33255f2da0b160f53135c56921d875c - refspec: refs/pull/7/merge + git: *git_ref_spec - name: SPECIFIC-REVISION | check HEAD after update with refspec command: git rev-parse HEAD @@ -144,7 +137,7 @@ - assert: that: - - 'git_result.stdout == "5473e343e33255f2da0b160f53135c56921d875c"' + - 'git_result.stdout == test_branch_ref_head_id' # Test that a forced shallow checkout referincing branch only always fetches latest head