summaryrefslogtreecommitdiff
path: root/test/integration/targets/git
diff options
context:
space:
mode:
authorSenya <senya@riseup.net>2018-05-22 22:33:22 +0000
committerSviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>2018-05-23 00:33:22 +0200
commit0a701ff74601748efa93fbc366e6368e53c39cd0 (patch)
tree847f2268244ab29a3035339bd1adaf27fbf69692 /test/integration/targets/git
parent7d2012fdd73336a874d39c746dbe993aa7c13e77 (diff)
downloadansible-0a701ff74601748efa93fbc366e6368e53c39cd0.tar.gz
Detect separate git dir and set git config path value appropriately
PR #38016 Co-authored-by: Sviatoslav Sydorenko <wk.cvs.github@sydorenko.org.ua>
Diffstat (limited to 'test/integration/targets/git')
-rw-r--r--test/integration/targets/git/tasks/main.yml3
-rw-r--r--test/integration/targets/git/tasks/separate-git-dir.yml64
2 files changed, 67 insertions, 0 deletions
diff --git a/test/integration/targets/git/tasks/main.yml b/test/integration/targets/git/tasks/main.yml
index a64fef1ef9..5520a28b4d 100644
--- a/test/integration/targets/git/tasks/main.yml
+++ b/test/integration/targets/git/tasks/main.yml
@@ -36,3 +36,6 @@
- include_tasks: reset-origin.yml
- include_tasks: ambiguous-ref.yml
- include_tasks: archive.yml
+- include_tasks: separate-git-dir.yml
+ when:
+ - git_version.stdout is version("1.7.5", '>=')
diff --git a/test/integration/targets/git/tasks/separate-git-dir.yml b/test/integration/targets/git/tasks/separate-git-dir.yml
new file mode 100644
index 0000000000..56ff6ef304
--- /dev/null
+++ b/test/integration/targets/git/tasks/separate-git-dir.yml
@@ -0,0 +1,64 @@
+# test code for repositories with separate git dir updating
+# see https://github.com/ansible/ansible/pull/38016
+# see https://github.com/ansible/ansible/issues/30034
+
+- name: SEPARATE-GIT-DIR | clear checkout_dir
+ file:
+ state: absent
+ path: '{{ checkout_dir }}'
+
+- name: create a tempdir for separate git dir
+ local_action: shell mktemp -du
+ register: tempdir
+
+- name: SEPARATE-GIT-DIR | clone with a separate git dir
+ command: git clone {{ repo_format1 }} {{ checkout_dir }} --separate-git-dir={{ tempdir.stdout }}
+
+- name: SEPARATE-GIT-DIR | update repo the usual way
+ git:
+ repo: "{{ repo_format1 }}"
+ dest: "{{ checkout_dir }}"
+
+- name: SEPARATE-GIT-DIR | set git dir to non-existent dir
+ shell: "echo gitdir: /dev/null/non-existent-dir > .git"
+ args:
+ chdir: "{{ checkout_dir }}"
+
+- name: SEPARATE-GIT-DIR | update repo the usual way
+ git:
+ repo: "{{ repo_format1 }}"
+ dest: "{{ checkout_dir }}"
+ ignore_errors: yes
+ register: result
+
+- name: SEPARATE-GIT-DIR | check update has failed
+ assert:
+ that:
+ - result is failed
+
+- name: SEPARATE-GIT-DIR | set .git file to bad format
+ shell: "echo some text gitdir: {{ checkout_dir }} > .git"
+ args:
+ chdir: "{{ checkout_dir }}"
+
+- name: SEPARATE-GIT-DIR | update repo the usual way
+ git:
+ repo: "{{ repo_format1 }}"
+ dest: "{{ checkout_dir }}"
+ ignore_errors: yes
+ register: result
+
+- name: SEPARATE-GIT-DIR | check update has failed
+ assert:
+ that:
+ - result is failed
+
+- name: SEPARATE-GIT-DIR | clear separate git dir
+ file:
+ state: absent
+ path: "{{ tempdir.stdout }}"
+
+- name: SEPARATE-GIT-DIR | clear checkout_dir
+ file:
+ state: absent
+ path: '{{ checkout_dir }}'