2017-01-06 23:38:53 +01:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
|
2017-10-13 16:30:15 +02:00
|
|
|
- name: SUBMODULES | clear checkout_dir
|
|
|
|
file:
|
|
|
|
state: absent
|
|
|
|
path: "{{ checkout_dir }}"
|
2017-01-06 23:38:53 +01:00
|
|
|
|
2017-10-13 16:30:15 +02:00
|
|
|
- name: SUBMODULES | Test that clone without recursive does not retrieve submodules
|
2017-01-06 23:38:53 +01:00
|
|
|
git:
|
2017-10-13 16:30:15 +02:00
|
|
|
repo: "{{ repo_submodules }}"
|
|
|
|
dest: "{{ checkout_dir }}"
|
2017-01-06 23:38:53 +01:00
|
|
|
recursive: no
|
|
|
|
|
|
|
|
- command: 'ls -1a {{ checkout_dir }}/submodule1'
|
|
|
|
register: submodule1
|
|
|
|
|
|
|
|
- assert:
|
2017-10-13 16:30:15 +02:00
|
|
|
that: '{{ submodule1.stdout_lines | length }} == 2'
|
2017-01-06 23:38:53 +01:00
|
|
|
|
2017-10-13 16:30:15 +02:00
|
|
|
- name: SUBMODULES | clear checkout_dir
|
|
|
|
file:
|
|
|
|
state: absent
|
|
|
|
path: "{{ checkout_dir }}"
|
2017-01-06 23:38:53 +01:00
|
|
|
|
|
|
|
|
2017-10-13 16:30:15 +02:00
|
|
|
- name: SUBMODULES | Test that clone with recursive retrieves submodules
|
2017-01-06 23:38:53 +01:00
|
|
|
git:
|
2017-10-13 16:30:15 +02:00
|
|
|
repo: "{{ repo_submodules }}"
|
|
|
|
dest: "{{ checkout_dir }}"
|
2017-01-06 23:38:53 +01:00
|
|
|
recursive: yes
|
|
|
|
|
|
|
|
- command: 'ls -1a {{ checkout_dir }}/submodule1'
|
|
|
|
register: submodule1
|
|
|
|
|
|
|
|
- assert:
|
2017-10-13 16:30:15 +02:00
|
|
|
that: '{{ submodule1.stdout_lines | length }} == 4'
|
2017-01-06 23:38:53 +01:00
|
|
|
|
2017-10-13 16:30:15 +02:00
|
|
|
- name: SUBMODULES | Copy the checkout so we can run several different tests on it
|
2017-01-06 23:38:53 +01:00
|
|
|
command: 'cp -pr {{ checkout_dir }} {{ checkout_dir }}.bak'
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-10-13 16:30:15 +02:00
|
|
|
- name: SUBMODULES | Test that update without recursive does not change submodules
|
2017-01-06 23:38:53 +01:00
|
|
|
command: 'git config --replace-all remote.origin.url {{ repo_submodules_newer }}'
|
|
|
|
args:
|
|
|
|
chdir: '{{ checkout_dir }}'
|
|
|
|
|
|
|
|
- git:
|
2017-10-13 16:30:15 +02:00
|
|
|
repo: "{{ repo_submodules_newer }}"
|
|
|
|
dest: "{{ checkout_dir }}"
|
2017-01-06 23:38:53 +01:00
|
|
|
recursive: no
|
|
|
|
update: yes
|
|
|
|
track_submodules: yes
|
|
|
|
|
|
|
|
- command: 'ls -1a {{ checkout_dir }}/submodule1'
|
|
|
|
register: submodule1
|
|
|
|
|
|
|
|
- stat:
|
2017-10-13 16:30:15 +02:00
|
|
|
path: "{{ checkout_dir }}/submodule2"
|
2017-01-06 23:38:53 +01:00
|
|
|
register: submodule2
|
|
|
|
|
2017-10-13 16:30:15 +02:00
|
|
|
- command: ls -1a {{ checkout_dir }}/submodule2
|
2017-01-06 23:38:53 +01:00
|
|
|
register: submodule2
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that: '{{ submodule1.stdout_lines|length }} == 4'
|
2017-10-13 16:30:15 +02:00
|
|
|
|
2017-01-06 23:38:53 +01:00
|
|
|
- assert:
|
|
|
|
that: '{{ submodule2.stdout_lines|length }} == 2'
|
|
|
|
|
|
|
|
|
2017-10-13 16:30:15 +02:00
|
|
|
- name: SUBMODULES | Restore checkout to prior state
|
|
|
|
file:
|
|
|
|
state: absent
|
|
|
|
path: "{{ checkout_dir }}"
|
2017-01-06 23:38:53 +01:00
|
|
|
- command: 'cp -pr {{ checkout_dir }}.bak {{ checkout_dir }}'
|
|
|
|
|
2017-10-13 16:30:15 +02:00
|
|
|
- name: SUBMODULES | Test that update with recursive updated existing submodules
|
2017-01-06 23:38:53 +01:00
|
|
|
command: 'git config --replace-all remote.origin.url {{ repo_submodules_newer }}'
|
|
|
|
args:
|
2017-10-13 16:30:15 +02:00
|
|
|
chdir: "{{ checkout_dir }}"
|
2017-01-06 23:38:53 +01:00
|
|
|
|
|
|
|
- git:
|
2017-10-13 16:30:15 +02:00
|
|
|
repo: "{{ repo_submodules_newer }}"
|
|
|
|
dest: "{{ checkout_dir }}"
|
2017-01-06 23:38:53 +01:00
|
|
|
update: yes
|
|
|
|
recursive: yes
|
|
|
|
track_submodules: yes
|
|
|
|
|
|
|
|
- command: 'ls -1a {{ checkout_dir }}/submodule1'
|
|
|
|
register: submodule1
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that: '{{ submodule1.stdout_lines|length }} == 5'
|
|
|
|
|
|
|
|
|
2017-10-13 16:30:15 +02:00
|
|
|
- name: SUBMODULES | Test that update with recursive found new submodules
|
2017-01-06 23:38:53 +01:00
|
|
|
command: 'ls -1a {{ checkout_dir }}/submodule2'
|
|
|
|
register: submodule2
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that: '{{ submodule2.stdout_lines|length }} == 4'
|