Debian Codegraph @

test/integration/targets/git/tasks/separate-git-dir.yml

raw
1 # test code for repositories with separate git dir updating
2 # see https://github.com/ansible/ansible/pull/38016
3 # see https://github.com/ansible/ansible/issues/30034
4
5 - name: SEPARATE-GIT-DIR | clear checkout_dir
6 file:
7 state: absent
8 path: '{{ checkout_dir }}'
9
10 - name: SEPARATE-GIT-DIR | make a pre-exist repo dir
11 file:
12 state: directory
13 path: '{{ separate_git_dir }}'
14
15 - name: SEPARATE-GIT-DIR | clone with a separate git dir
16 git:
17 repo: '{{ repo_format1 }}'
18 dest: '{{ checkout_dir }}'
19 separate_git_dir: '{{ separate_git_dir }}'
20 ignore_errors: yes
21 register: result
22
23 - name: SEPARATE-GIT-DIR | the clone will fail due to pre-exist dir
24 assert:
25 that: 'result is failed'
26
27 - name: SEPARATE-GIT-DIR | delete pre-exist dir
28 file:
29 state: absent
30 path: '{{ separate_git_dir }}'
31
32 - name: SEPARATE-GIT-DIR | clone again with a separate git dir
33 git:
34 repo: '{{ repo_format1 }}'
35 dest: '{{ checkout_dir }}'
36 separate_git_dir: '{{ separate_git_dir }}'
37
38 - name: SEPARATE-GIT-DIR | check the stat of git dir
39 stat:
40 path: '{{ separate_git_dir }}'
41 register: stat_result
42
43 - name: SEPARATE-GIT-DIR | the git dir should exist
44 assert:
45 that: 'stat_result.stat.exists == True'
46
47 - name: SEPARATE-GIT-DIR | update repo the usual way
48 git:
49 repo: '{{ repo_format1 }}'
50 dest: '{{ checkout_dir }}'
51 separate_git_dir: '{{ separate_git_dir }}'
52 register: result
53
54 - name: SEPARATE-GIT-DIR | update should not fail
55 assert:
56 that:
57 - result is not failed
58
59 - name: SEPARATE-GIT-DIR | move the git dir to new place
60 git:
61 repo: '{{ repo_format1 }}'
62 dest: '{{ checkout_dir }}'
63 separate_git_dir: '{{ separate_git_dir }}_new'
64 register: result
65
66 - name: SEPARATE-GIT-DIR | the movement should not failed
67 assert:
68 that: 'result is not failed'
69
70 - name: SEPARATE-GIT-DIR | check the stat of new git dir
71 stat:
72 path: '{{ separate_git_dir }}_new'
73 register: stat_result
74
75 - name: SEPARATE-GIT-DIR | the new git dir should exist
76 assert:
77 that: 'stat_result.stat.exists == True'
78
79 - name: SEPARATE-GIT-DIR | test the update
80 git:
81 repo: '{{ repo_format1 }}'
82 dest: '{{ checkout_dir }}'
83 register: result
84
85 - name: SEPARATE-GIT-DIR | the update should not failed
86 assert:
87 that:
88 - result is not failed
89
90 - name: SEPARATE-GIT-DIR | set git dir to non-existent dir
91 shell: "echo gitdir: /dev/null/non-existent-dir > .git"
92 args:
93 chdir: "{{ checkout_dir }}"
94
95 - name: SEPARATE-GIT-DIR | update repo the usual way
96 git:
97 repo: "{{ repo_format1 }}"
98 dest: "{{ checkout_dir }}"
99 ignore_errors: yes
100 register: result
101
102 - name: SEPARATE-GIT-DIR | check update has failed
103 assert:
104 that:
105 - result is failed
106
107 - name: SEPARATE-GIT-DIR | set .git file to bad format
108 shell: "echo some text gitdir: {{ checkout_dir }} > .git"
109 args:
110 chdir: "{{ checkout_dir }}"
111
112 - name: SEPARATE-GIT-DIR | update repo the usual way
113 git:
114 repo: "{{ repo_format1 }}"
115 dest: "{{ checkout_dir }}"
116 ignore_errors: yes
117 register: result
118
119 - name: SEPARATE-GIT-DIR | check update has failed
120 assert:
121 that:
122 - result is failed
123
124 - name: SEPARATE-GIT-DIR | clear separate git dir
125 file:
126 state: absent
127 path: "{{ separate_git_dir }}_new"
128
129 - name: SEPARATE-GIT-DIR | clear checkout_dir
130 file:
131 state: absent
132 path: '{{ checkout_dir }}'