summaryrefslogtreecommitdiff
path: root/test/integration
diff options
context:
space:
mode:
authorRobin Roth <robin-roth@online.de>2016-07-05 21:07:42 +0200
committerjctanner <tanner.jc@gmail.com>2016-07-05 15:07:42 -0400
commitd0ccedc617844671d25fb2e0a2ac717eb7a9a076 (patch)
tree0b3163ba4de92daad242c007ea56c13bc742b9e3 /test/integration
parentd51917f306c78d023bb9c45444a6e5b1cf0cd61c (diff)
downloadansible-d0ccedc617844671d25fb2e0a2ac717eb7a9a076.tar.gz
Fix git shallow update (#16224)
* add git shallow fetch test covers https://github.com/ansible/ansible-modules-core/issues/3782 updating a repo with depth=1 fails silently if version==HEAD * raise git version support supporting depth to 1.9.1
Diffstat (limited to 'test/integration')
-rw-r--r--test/integration/roles/test_git/tasks/main.yml56
1 files changed, 51 insertions, 5 deletions
diff --git a/test/integration/roles/test_git/tasks/main.yml b/test/integration/roles/test_git/tasks/main.yml
index 18eaeffdfe..4e4ab1cc9a 100644
--- a/test/integration/roles/test_git/tasks/main.yml
+++ b/test/integration/roles/test_git/tasks/main.yml
@@ -19,6 +19,7 @@
- name: set role facts
set_fact:
checkout_dir: '{{ output_dir }}/git'
+ repo_dir: '{{ output_dir }}/local_repos'
repo_format1: 'https://github.com/jimi-c/test_role'
repo_format2: 'git@github.com:jimi-c/test_role.git'
repo_format3: 'ssh://git@github.com/jimi-c/test_role.git'
@@ -33,6 +34,7 @@
known_host_files:
- "{{ lookup('env','HOME') }}/.ssh/known_hosts"
- '/etc/ssh/ssh_known_hosts'
+ git_version_supporting_depth: 1.9.1
- name: clean out the output_dir
shell: rm -rf {{ output_dir }}/*
@@ -40,10 +42,15 @@
- name: verify that git is installed so this test can continue
shell: which git
-- name: get git version, only newer than 1.8.2 has fixed git depth
+- name: get git version, only newer than {{git_version_supporting_depth}} has fixed git depth
shell: git --version | grep 'git version' | sed 's/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/...
@@ -259,7 +266,7 @@
that:
- checkout_shallow.rc == 1
- checkout_shallow|failed
- when: git_version.stdout | version_compare("1.8.2", '>=')
+ when: git_version.stdout | version_compare("{{git_version_supporting_depth}}", '>=')
- name: clear checkout_dir
file: state=absent path={{ checkout_dir }}
@@ -476,7 +483,7 @@
- name: make sure the old commit was not fetched
assert:
that: checkout_early.rc == 1
- when: git_version.stdout | version_compare("1.8.2", '>=')
+ 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
@@ -488,7 +495,7 @@
- assert:
that: "not checkout2|changed"
- when: git_version.stdout | version_compare("1.8.2", '>=')
+ when: git_version.stdout | version_compare("{{git_version_supporting_depth}}", '>=')
- name: again try to access earlier commit
shell: git checkout 79624b4
@@ -500,7 +507,7 @@
- name: again make sure the old commit was not fetched
assert:
that: checkout_early.rc == 1
- when: git_version.stdout | version_compare("1.8.2", '>=')
+ 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
@@ -611,3 +618,42 @@
- 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
+ file: state=absent path={{ checkout_dir }}
+