summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToshio Kuratomi <a.badger@gmail.com>2016-12-14 08:46:11 -0800
committerToshio Kuratomi <a.badger@gmail.com>2016-12-14 08:46:11 -0800
commit00378515e245141370ada388f60cc98ccfacb74c (patch)
treecae7eb1160494fe8c508bd5be7aaf543fd2438e6
parent2639016847329f63c17d3d703c96661aaf14b9d6 (diff)
downloadansible-00378515e245141370ada388f60cc98ccfacb74c.tar.gz
* Add test for git with local modifications
(cherry picked from afca95739630891d5678d362362877270ae2e80e) From PR: Fix UnboundLocalError remote_head in git (#19057)
-rw-r--r--test/integration/roles/test_git/tasks/main.yml111
1 files changed, 107 insertions, 4 deletions
diff --git a/test/integration/roles/test_git/tasks/main.yml b/test/integration/roles/test_git/tasks/main.yml
index 452a23201b..30e282c702 100644
--- a/test/integration/roles/test_git/tasks/main.yml
+++ b/test/integration/roles/test_git/tasks/main.yml
@@ -447,7 +447,7 @@
- name: clear checkout_dir
file: state=absent path={{ checkout_dir }}
-- name: Clone example git repo that we're going to modify
+- name: "Clone example git repo that we're going to modify"
git:
repo: '{{ repo_update_url_1 }}'
dest: '{{ checkout_dir }}/repo'
@@ -652,9 +652,6 @@
register: git_fetch
ignore_errors: yes
-- name: read file
- shell: cat {{ checkout_dir }}/a
-
- name: check update arrived
assert:
that:
@@ -718,3 +715,109 @@
gpg_version.stdout and
(git_version.stdout | version_compare("2.1.0", '>=') or
gpg_version.stdout | version_compare("1.4.16", '>='))
+
+- name: clear checkout_dir
+ file: state=absent path={{ checkout_dir }}
+
+# test for https://github.com/ansible/ansible-modules-core/pull/5505
+- name: prepare old git repo
+ shell: rm -rf localmods; mkdir localmods; cd localmods; git init; echo "1" > a; git add a; git commit -m "1"
+ args:
+ chdir: "{{repo_dir}}"
+
+- name: checkout old repo
+ git:
+ repo: '{{ repo_dir }}/localmods'
+ dest: '{{ checkout_dir }}'
+
+- name: "update repo"
+ shell: echo "2" > a; git commit -a -m "2"
+ args:
+ chdir: "{{repo_dir}}/localmods"
+
+- name: "add local mods"
+ shell: echo "3" > a
+ args:
+ chdir: "{{ checkout_dir }}"
+
+- name: fetch with local mods without force (should fail)
+ git:
+ repo: '{{ repo_dir }}/localmods'
+ dest: '{{ checkout_dir }}'
+ register: git_fetch
+ ignore_errors: yes
+
+- name: check fetch with localmods failed
+ assert:
+ that:
+ - git_fetch|failed
+
+- name: fetch with local mods with force
+ git:
+ repo: '{{ repo_dir }}/localmods'
+ dest: '{{ checkout_dir }}'
+ force: True
+ register: git_fetch_force
+ ignore_errors: yes
+
+- name: check update arrived
+ assert:
+ that:
+ - "{{ lookup('file', checkout_dir+'/a' )}} == 2"
+ - git_fetch_force|changed
+
+- name: clear checkout_dir
+ file: state=absent path={{ checkout_dir }}
+
+# localmods and shallow clone
+- name: prepare old git repo
+ shell: rm -rf localmods; mkdir localmods; cd localmods; git init; echo "1" > a; git add a; git commit -m "1"
+ args:
+ chdir: "{{repo_dir}}"
+
+- name: checkout old repo
+ git:
+ repo: '{{ repo_dir }}/localmods'
+ dest: '{{ checkout_dir }}'
+ depth: 1
+
+- name: "update repo"
+ shell: echo "2" > a; git commit -a -m "2"
+ args:
+ chdir: "{{repo_dir}}/localmods"
+
+- name: "add local mods"
+ shell: echo "3" > a
+ args:
+ chdir: "{{ checkout_dir }}"
+
+- name: fetch with local mods without force (should fail)
+ git:
+ repo: '{{ repo_dir }}/localmods'
+ dest: '{{ checkout_dir }}'
+ depth: 1
+ register: git_fetch
+ ignore_errors: yes
+
+- name: check fetch with localmods failed
+ assert:
+ that:
+ - git_fetch|failed
+
+- name: fetch with local mods with force
+ git:
+ repo: '{{ repo_dir }}/localmods'
+ dest: '{{ checkout_dir }}'
+ depth: 1
+ force: True
+ register: git_fetch_force
+ ignore_errors: yes
+
+- name: check update arrived
+ assert:
+ that:
+ - "{{ lookup('file', checkout_dir+'/a' )}} == 2"
+ - git_fetch_force|changed
+
+- name: clear checkout_dir
+ file: state=absent path={{ checkout_dir }}