diff --git a/test/integration/roles/test_git/tasks/main.yml b/test/integration/roles/test_git/tasks/main.yml index 792dd0dc3bb..18eaeffdfec 100644 --- a/test/integration/roles/test_git/tasks/main.yml +++ b/test/integration/roles/test_git/tasks/main.yml @@ -559,6 +559,55 @@ - "'newtag' in listoftags.stdout_lines" +- name: clear checkout_dir + file: state=absent path={{ checkout_dir }} + + + # Test for https://github.com/ansible/ansible-modules-core/issues/3456 + # clone a repo with depth and version specified + +- name: clone repo with both version and depth specified + git: + repo: '{{ repo_depth_url }}' + dest: '{{ checkout_dir }}' + depth: 1 + version: master + +- name: run a second time (now fetch, not clone) + git: + repo: '{{ repo_depth_url }}' + dest: '{{ checkout_dir }}' + depth: 1 + version: master + register: git_fetch + +- name: ensure the fetch succeeded + assert: + that: git_fetch|success + + +- name: clear checkout_dir + file: state=absent path={{ checkout_dir }} + +- name: clone repo with both version and depth specified + git: + repo: '{{ repo_depth_url }}' + dest: '{{ checkout_dir }}' + depth: 1 + version: master + +- name: switch to older branch with depth=1 (uses fetch) + git: + repo: '{{ repo_depth_url }}' + dest: '{{ checkout_dir }}' + depth: 1 + version: earlybranch + register: git_fetch + +- name: ensure the fetch succeeded + assert: + that: git_fetch|success + - name: clear checkout_dir file: state=absent path={{ checkout_dir }}