summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/git/tasks/separate-git-dir.yml
blob: 5b87404396f23741a22ee7ea168390111deaac9c (plain)
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
# 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: SEPARATE-GIT-DIR | make a pre-exist repo dir
  file:
    state: directory
    path: '{{ separate_git_dir }}'

- name: SEPARATE-GIT-DIR | clone with a separate git dir
  git:
    repo: '{{ repo_format1 }}'
    dest: '{{ checkout_dir }}'
    separate_git_dir: '{{ separate_git_dir }}'
  ignore_errors: yes
  register: result

- name: SEPARATE-GIT-DIR | the clone will fail due to pre-exist dir
  assert:
    that: 'result is failed'

- name: SEPARATE-GIT-DIR | delete pre-exist dir
  file:
    state: absent
    path: '{{ separate_git_dir }}'

- name: SEPARATE-GIT-DIR | clone again with a separate git dir
  git:
    repo: '{{ repo_format1 }}'
    dest: '{{ checkout_dir }}'
    separate_git_dir: '{{ separate_git_dir }}'

- name: SEPARATE-GIT-DIR | check the stat of git dir
  stat:
    path: '{{ separate_git_dir }}'
  register: stat_result

- name: SEPARATE-GIT-DIR | the git dir should exist
  assert:
    that: 'stat_result.stat.exists == True'

- name: SEPARATE-GIT-DIR | update repo the usual way
  git:
    repo: '{{ repo_format1 }}'
    dest: '{{ checkout_dir }}'
    separate_git_dir: '{{ separate_git_dir }}'
  register: result

- name: SEPARATE-GIT-DIR | update should not fail
  assert:
    that:
      - result is not failed

- name: SEPARATE-GIT-DIR | move the git dir to new place
  git:
    repo: '{{ repo_format1 }}'
    dest: '{{ checkout_dir }}'
    separate_git_dir: '{{ separate_git_dir }}_new'
  register: result

- name: SEPARATE-GIT-DIR | the movement should not failed
  assert:
    that: 'result is not failed'

- name: SEPARATE-GIT-DIR | check the stat of new git dir
  stat:
    path: '{{ separate_git_dir }}_new'
  register: stat_result

- name: SEPARATE-GIT-DIR | the new git dir should exist
  assert:
    that: 'stat_result.stat.exists == True'

- name: SEPARATE-GIT-DIR | test the update
  git:
    repo: '{{ repo_format1 }}'
    dest: '{{ checkout_dir }}'
  register: result

- name: SEPARATE-GIT-DIR | the update should not failed
  assert:
    that:
      - result is not failed

- 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: "{{ separate_git_dir }}_new"

- name: SEPARATE-GIT-DIR | clear checkout_dir
  file:
    state: absent
    path: '{{ checkout_dir }}'