--- # Test the depth option and fetching revisions that were ignored first - name: clear checkout_dir file: state=absent path={{ checkout_dir }} - name: Clone example git repo with depth 1 git: repo: 'file://{{ repo_dir|expanduser }}/shallow' dest: '{{ checkout_dir }}' depth: 1 - name: try to access earlier commit command: "git checkout {{git_shallow_head_1.stdout}}" register: checkout_early failed_when: False args: chdir: '{{ checkout_dir }}' - name: make sure the old commit was not fetched assert: that: 'checkout_early.rc != 0' when: git_version.stdout | version_compare("{{git_version_supporting_depth}}", '>=') # tests https://github.com/ansible/ansible/issues/14954 - name: fetch repo again with depth=1 git: repo: 'file://{{ repo_dir|expanduser }}/shallow' dest: '{{ checkout_dir }}' depth: 1 register: checkout2 - assert: that: "not checkout2|changed" when: git_version.stdout | version_compare("{{git_version_supporting_depth}}", '>=') - name: again try to access earlier commit shell: "git checkout {{git_shallow_head_1.stdout}}" register: checkout_early failed_when: False args: chdir: '{{ checkout_dir }}' - name: again make sure the old commit was not fetched assert: that: 'checkout_early.rc != 0' when: git_version.stdout | version_compare("{{git_version_supporting_depth}}", '>=') # make sure we are still able to fetch other versions - name: Clone same repo with older version git: repo: 'file://{{ repo_dir|expanduser }}/shallow' dest: '{{ checkout_dir }}' depth: 1 version: earlytag register: cloneold - assert: that: "cloneold|success" - name: try to access earlier commit shell: "git checkout {{git_shallow_head_1.stdout}}" args: chdir: '{{ checkout_dir }}' - name: clear checkout_dir file: state: absent path: "{{ checkout_dir }}" # Test for https://github.com/ansible/ansible/issues/21316 - name: Shallow clone with tag git: repo: 'file://{{ repo_dir|expanduser }}/shallow' dest: '{{ checkout_dir }}' depth: 1 version: earlytag register: cloneold - assert: that: "cloneold|success" - 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: 'file://{{ repo_dir|expanduser }}/shallow' dest: '{{ checkout_dir }}' depth: 1 version: master - name: run a second time (now fetch, not clone) git: repo: 'file://{{ repo_dir|expanduser }}/shallow' 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: 'file://{{ repo_dir|expanduser }}/shallow' dest: '{{ checkout_dir }}' depth: 1 version: master - name: switch to older branch with depth=1 (uses fetch) git: repo: 'file://{{ repo_dir|expanduser }}/shallow' 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 }} # test for https://github.com/ansible/ansible-modules-core/issues/3782 # make sure shallow fetch works when no version is specified - name: checkout old repo git: repo: 'file://{{ repo_dir|expanduser }}/shallow' dest: '{{ checkout_dir }}' depth: 1 - name: "update repo" shell: echo "3" > a; git commit -a -m "3" args: chdir: "{{repo_dir}}/shallow" - name: fetch updated repo git: repo: 'file://{{ repo_dir|expanduser }}/shallow' dest: '{{ checkout_dir }}' depth: 1 register: git_fetch ignore_errors: yes - name: check update arrived assert: that: - "{{ lookup('file', checkout_dir+'/a' )}} == 3" - git_fetch|changed - name: clear checkout_dir file: state: absent path: "{{ checkout_dir }}"