1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
|
#
# Submodule tests
#
# Repository A with submodules defined (repo_submodules)
# .gitmodules file points to Repository I
# Repository B forked from A that has newer commits (repo_submodules_newer)
# .gitmodules file points to Repository II instead of I
# .gitmodules file also points to Repository III
# Repository I for submodule1 (repo_submodule1)
# Has 1 file checked in
# Repository II forked from I that has newer commits (repo_submodule1_newer)
# Has 2 files checked in
# Repository III for a second submodule (repo_submodule2)
# Has 1 file checked in
- name: SUBMODULES | clear checkout_dir
file:
state: absent
path: "{{ checkout_dir }}"
- name: SUBMODULES | Test that clone without recursive does not retrieve submodules
git:
repo: "{{ repo_submodules }}"
version: 45c6c07ef10fd9e453d90207e63da1ce5bd3ae1e
dest: "{{ checkout_dir }}"
recursive: no
- name: SUBMODULES | List submodule1
command: 'ls -1a {{ checkout_dir }}/submodule1'
register: submodule1
- name: SUBMODULES | Ensure submodule1 is at the appropriate commit
assert:
that: submodule1.stdout_lines | length == 2
- name: SUBMODULES | clear checkout_dir
file:
state: absent
path: "{{ checkout_dir }}"
- name: SUBMODULES | Test that clone with recursive retrieves submodules
git:
repo: "{{ repo_submodules }}"
dest: "{{ checkout_dir }}"
version: 45c6c07ef10fd9e453d90207e63da1ce5bd3ae1e
recursive: yes
- name: SUBMODULES | List submodule1
command: 'ls -1a {{ checkout_dir }}/submodule1'
register: submodule1
- name: SUBMODULES | Ensure submodule1 is at the appropriate commit
assert:
that: submodule1.stdout_lines | length == 4
- name: SUBMODULES | Copy the checkout so we can run several different tests on it
command: 'cp -pr {{ checkout_dir }} {{ checkout_dir }}.bak'
- name: SUBMODULES | Test that update without recursive does not change submodules
git:
repo: "{{ repo_submodules }}"
version: d2974e4bbccdb59368f1d5eff2205f0fa863297e
dest: "{{ checkout_dir }}"
recursive: no
update: yes
track_submodules: yes
- name: SUBMODULES | List submodule1
command: 'ls -1a {{ checkout_dir }}/submodule1'
register: submodule1
- name: SUBMODULES | Stat submodule2
stat:
path: "{{ checkout_dir }}/submodule2"
register: submodule2
- name: SUBMODULES | List submodule2
command: ls -1a {{ checkout_dir }}/submodule2
register: submodule2
- name: SUBMODULES | Ensure both submodules are at the appropriate commit
assert:
that:
- submodule1.stdout_lines|length == 4
- submodule2.stdout_lines|length == 2
- name: SUBMODULES | Remove checkout dir
file:
state: absent
path: "{{ checkout_dir }}"
- name: SUBMODULES | Restore checkout to prior state
command: 'cp -pr {{ checkout_dir }}.bak {{ checkout_dir }}'
- name: SUBMODULES | Test that update with recursive updated existing submodules
git:
repo: "{{ repo_submodules }}"
version: d2974e4bbccdb59368f1d5eff2205f0fa863297e
dest: "{{ checkout_dir }}"
update: yes
recursive: yes
track_submodules: yes
- name: SUBMODULES | List submodule 1
command: 'ls -1a {{ checkout_dir }}/submodule1'
register: submodule1
- name: SUBMODULES | Ensure submodule1 is at the appropriate commit
assert:
that: submodule1.stdout_lines | length == 5
- name: SUBMODULES | Test that update with recursive found new submodules
command: 'ls -1a {{ checkout_dir }}/submodule2'
register: submodule2
- name: SUBMODULES | Enusre submodule2 is at the appropriate commit
assert:
that: submodule2.stdout_lines | length == 4
- name: SUBMODULES | clear checkout_dir
file:
state: absent
path: "{{ checkout_dir }}"
- name: SUBMODULES | Clone main submodule repository
git:
repo: "{{ repo_submodules }}"
dest: "{{ checkout_dir }}/test.gitdir"
version: 45c6c07ef10fd9e453d90207e63da1ce5bd3ae1e
recursive: yes
- name: SUBMODULES | Test that cloning submodule with .git in directory name works
git:
repo: "{{ repo_submodule1 }}"
dest: "{{ checkout_dir }}/test.gitdir/submodule1"
- name: SUBMODULES | List submodule1
command: 'ls -1a {{ checkout_dir }}/test.gitdir/submodule1'
register: submodule1
- name: SUBMODULES | Ensure submodule1 is at the appropriate commit
assert:
that: submodule1.stdout_lines | length == 4
|