|
|
|
@ -29,6 +29,7 @@
|
|
|
|
|
repo_submodule2: 'https://github.com/abadger/test_submodules_subm2.git'
|
|
|
|
|
repo_update_url_1: 'https://github.com/ansible-test-robinro/git-test-old'
|
|
|
|
|
repo_update_url_2: 'https://github.com/ansible-test-robinro/git-test-new'
|
|
|
|
|
repo_depth_url: 'https://github.com/ansible-test-robinro/git-test-shallow-depth'
|
|
|
|
|
known_host_files:
|
|
|
|
|
- "{{ lookup('env','HOME') }}/.ssh/known_hosts"
|
|
|
|
|
- '/etc/ssh/ssh_known_hosts'
|
|
|
|
@ -43,6 +44,7 @@
|
|
|
|
|
# Test repo=https://github.com/...
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: initial checkout
|
|
|
|
|
git: repo={{ repo_format1 }} dest={{ checkout_dir }}
|
|
|
|
|
register: git_result
|
|
|
|
@ -220,6 +222,39 @@
|
|
|
|
|
that:
|
|
|
|
|
- 'git_result.stdout == "2cfde3668b8bb10fbe2b9d5cec486025ad8cc51b"'
|
|
|
|
|
|
|
|
|
|
# try out combination of refspec and depth
|
|
|
|
|
- name: clear checkout_dir
|
|
|
|
|
file: state=absent path={{ checkout_dir }}
|
|
|
|
|
|
|
|
|
|
- name: update to revision by specifying the refspec with depth=1
|
|
|
|
|
git:
|
|
|
|
|
repo: https://github.com/ansible/ansible-examples.git
|
|
|
|
|
dest: '{{ checkout_dir }}'
|
|
|
|
|
version: 2cfde3668b8bb10fbe2b9d5cec486025ad8cc51b
|
|
|
|
|
refspec: refs/pull/7/merge
|
|
|
|
|
depth: 1
|
|
|
|
|
|
|
|
|
|
- name: check HEAD after update with refspec
|
|
|
|
|
command: git rev-parse HEAD chdir="{{ checkout_dir }}"
|
|
|
|
|
register: git_result
|
|
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
|
that:
|
|
|
|
|
- 'git_result.stdout == "2cfde3668b8bb10fbe2b9d5cec486025ad8cc51b"'
|
|
|
|
|
|
|
|
|
|
- name: try to access other commit
|
|
|
|
|
shell: git checkout 0ce1096
|
|
|
|
|
register: checkout_shallow
|
|
|
|
|
failed_when: False
|
|
|
|
|
args:
|
|
|
|
|
chdir: '{{ checkout_dir }}'
|
|
|
|
|
|
|
|
|
|
- name: make sure the old commit was not fetched
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- checkout_shallow.rc == 1
|
|
|
|
|
- checkout_shallow|failed
|
|
|
|
|
|
|
|
|
|
- name: clear checkout_dir
|
|
|
|
|
file: state=absent path={{ checkout_dir }}
|
|
|
|
|
|
|
|
|
@ -412,3 +447,109 @@
|
|
|
|
|
repo: '{{ checkout_dir}}/repo'
|
|
|
|
|
version: 'new-branch'
|
|
|
|
|
dest: '{{ checkout_dir }}/checkout'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 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: '{{ repo_depth_url }}'
|
|
|
|
|
dest: '{{ checkout_dir }}'
|
|
|
|
|
depth: 1
|
|
|
|
|
|
|
|
|
|
- name: try to access earlier commit
|
|
|
|
|
shell: git checkout 79624b4
|
|
|
|
|
register: checkout_early
|
|
|
|
|
failed_when: False
|
|
|
|
|
args:
|
|
|
|
|
chdir: '{{ checkout_dir }}'
|
|
|
|
|
|
|
|
|
|
- name: make sure the old commit was not fetched
|
|
|
|
|
assert:
|
|
|
|
|
that: checkout_early.rc == 1
|
|
|
|
|
|
|
|
|
|
# tests https://github.com/ansible/ansible/issues/14954
|
|
|
|
|
- name: fetch repo again with depth=1
|
|
|
|
|
git:
|
|
|
|
|
repo: '{{ repo_depth_url }}'
|
|
|
|
|
dest: '{{ checkout_dir }}'
|
|
|
|
|
depth: 1
|
|
|
|
|
register: checkout2
|
|
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
|
that: "not checkout2|changed"
|
|
|
|
|
|
|
|
|
|
- name: again try to access earlier commit
|
|
|
|
|
shell: git checkout 79624b4
|
|
|
|
|
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 == 1
|
|
|
|
|
|
|
|
|
|
# make sure we are still able to fetch other versions
|
|
|
|
|
- name: Clone same repo with older version
|
|
|
|
|
git:
|
|
|
|
|
repo: '{{ repo_depth_url }}'
|
|
|
|
|
dest: '{{ checkout_dir }}'
|
|
|
|
|
depth: 1
|
|
|
|
|
version: earlytag
|
|
|
|
|
register: cloneold
|
|
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
|
that: "cloneold|success"
|
|
|
|
|
|
|
|
|
|
- name: try to access earlier commit
|
|
|
|
|
shell: git checkout 79624b4
|
|
|
|
|
args:
|
|
|
|
|
chdir: '{{ checkout_dir }}'
|
|
|
|
|
|
|
|
|
|
# test for https://github.com/ansible/ansible-modules-core/issues/527
|
|
|
|
|
# clone a repo, add a tag to the same commit and try to checkout the new commit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: clear checkout_dir
|
|
|
|
|
file: state=absent path={{ checkout_dir }}
|
|
|
|
|
|
|
|
|
|
- name: checkout example repo
|
|
|
|
|
git: repo={{ repo_format1 }} dest={{ checkout_dir }}
|
|
|
|
|
|
|
|
|
|
- name: clone example repo locally
|
|
|
|
|
git: repo={{ checkout_dir }} dest={{checkout_dir}}.copy
|
|
|
|
|
|
|
|
|
|
- name: get tags of head
|
|
|
|
|
command: git tag --contains chdir="{{ checkout_dir }}.copy"
|
|
|
|
|
register: listoftags
|
|
|
|
|
|
|
|
|
|
- name: make sure the tag does not yet exist
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- "'newtag' not in listoftags.stdout_lines"
|
|
|
|
|
|
|
|
|
|
- name: add tag in orig repo
|
|
|
|
|
command: git tag newtag chdir="{{ checkout_dir }}"
|
|
|
|
|
|
|
|
|
|
- name: update copy with new tag
|
|
|
|
|
git: repo={{ checkout_dir }} dest={{checkout_dir}}.copy version=newtag
|
|
|
|
|
register: update_new_tag
|
|
|
|
|
|
|
|
|
|
- name: get tags of new head
|
|
|
|
|
command: git tag --contains chdir="{{ checkout_dir }}.copy"
|
|
|
|
|
register: listoftags
|
|
|
|
|
|
|
|
|
|
- name: check new head
|
|
|
|
|
assert:
|
|
|
|
|
that:
|
|
|
|
|
- not update_new_tag|changed
|
|
|
|
|
- "'newtag' in listoftags.stdout_lines"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: clear checkout_dir
|
|
|
|
|
file: state=absent path={{ checkout_dir }}
|
|
|
|
|
|
|
|
|
|