|
|
@ -19,7 +19,6 @@
|
|
|
|
- name: set role facts
|
|
|
|
- name: set role facts
|
|
|
|
set_fact:
|
|
|
|
set_fact:
|
|
|
|
checkout_dir: '{{ output_dir }}/git'
|
|
|
|
checkout_dir: '{{ output_dir }}/git'
|
|
|
|
repo_dir: '{{ output_dir }}/local_repos'
|
|
|
|
|
|
|
|
repo_format1: 'https://github.com/jimi-c/test_role'
|
|
|
|
repo_format1: 'https://github.com/jimi-c/test_role'
|
|
|
|
repo_format2: 'git@github.com:jimi-c/test_role.git'
|
|
|
|
repo_format2: 'git@github.com:jimi-c/test_role.git'
|
|
|
|
repo_format3: 'ssh://git@github.com/jimi-c/test_role.git'
|
|
|
|
repo_format3: 'ssh://git@github.com/jimi-c/test_role.git'
|
|
|
@ -45,11 +44,6 @@
|
|
|
|
shell: git --version | grep 'git version' | sed 's/git version //'
|
|
|
|
shell: git --version | grep 'git version' | sed 's/git version //'
|
|
|
|
register: git_version
|
|
|
|
register: git_version
|
|
|
|
|
|
|
|
|
|
|
|
- name: set dummy git config
|
|
|
|
|
|
|
|
shell: git config --global user.email "noreply@example.com"; git config --global user.name "Ansible Test Runner"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: create repo_dir
|
|
|
|
|
|
|
|
file: path={{repo_dir}} state=directory
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Test repo=https://github.com/...
|
|
|
|
# Test repo=https://github.com/...
|
|
|
@ -601,7 +595,6 @@
|
|
|
|
dest: '{{ checkout_dir }}'
|
|
|
|
dest: '{{ checkout_dir }}'
|
|
|
|
depth: 1
|
|
|
|
depth: 1
|
|
|
|
version: master
|
|
|
|
version: master
|
|
|
|
when: git_version.stdout | version_compare("1.8.2", '>=')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: switch to older branch with depth=1 (uses fetch)
|
|
|
|
- name: switch to older branch with depth=1 (uses fetch)
|
|
|
|
git:
|
|
|
|
git:
|
|
|
@ -610,51 +603,10 @@
|
|
|
|
depth: 1
|
|
|
|
depth: 1
|
|
|
|
version: earlybranch
|
|
|
|
version: earlybranch
|
|
|
|
register: git_fetch
|
|
|
|
register: git_fetch
|
|
|
|
when: git_version.stdout | version_compare("1.8.2", '>=')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: ensure the fetch succeeded
|
|
|
|
- name: ensure the fetch succeeded
|
|
|
|
assert:
|
|
|
|
assert:
|
|
|
|
that: git_fetch|success
|
|
|
|
that: git_fetch|success
|
|
|
|
when: git_version.stdout | version_compare("1.8.2", '>=')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- 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: prepare old git repo
|
|
|
|
|
|
|
|
shell: git init; echo "1" > a; git add a; git commit -m "1"
|
|
|
|
|
|
|
|
args:
|
|
|
|
|
|
|
|
chdir: "{{repo_dir}}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: checkout old repo
|
|
|
|
|
|
|
|
git:
|
|
|
|
|
|
|
|
repo: '{{ repo_dir }}'
|
|
|
|
|
|
|
|
dest: '{{ checkout_dir }}'
|
|
|
|
|
|
|
|
depth: 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: "update repo"
|
|
|
|
|
|
|
|
shell: echo "2" > a; git commit -a -m "2"
|
|
|
|
|
|
|
|
args:
|
|
|
|
|
|
|
|
chdir: "{{repo_dir}}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: fetch updated repo
|
|
|
|
|
|
|
|
git:
|
|
|
|
|
|
|
|
repo: '{{ repo_dir }}'
|
|
|
|
|
|
|
|
dest: '{{ checkout_dir }}'
|
|
|
|
|
|
|
|
depth: 1
|
|
|
|
|
|
|
|
register: git_fetch
|
|
|
|
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: read file
|
|
|
|
|
|
|
|
shell: cat {{ checkout_dir }}/a
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: check update arrived
|
|
|
|
|
|
|
|
assert:
|
|
|
|
|
|
|
|
that:
|
|
|
|
|
|
|
|
- "{{ lookup('file', checkout_dir+'/a' )}} == 2"
|
|
|
|
|
|
|
|
- git_fetch|changed
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: clear checkout_dir
|
|
|
|
- name: clear checkout_dir
|
|
|
|
file: state=absent path={{ checkout_dir }}
|
|
|
|
file: state=absent path={{ checkout_dir }}
|
|
|
|