summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/git/tasks/checkout-new-tag.yml
blob: eac73f679b03b36f8804f472c7432b49159a1ac9 (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
# test for  https://github.com/ansible/ansible-modules-core/issues/527
# clone a repo, add a tag to the same commit and try to checkout the new commit


- name: clear checkout_dir
  file:
    state: absent
    path: "{{ checkout_dir }}"

- name: checkout example repo
  git:
    repo: "{{ repo_dir }}/format1"
    dest: "{{ checkout_dir }}"

- name: get tags of head
  command: git tag --contains
  args:
    chdir: "{{ checkout_dir }}"
  register: listoftags

- name: make sure the tag does not yet exist
  assert:
    that:
      - "'newtag' not in listoftags.stdout_lines"

- name: add tag in orig repo
  command: git tag newtag
  args:
    chdir: "{{ repo_dir }}/format1"

- name: update copy with new tag
  git:
    repo: "{{ repo_dir }}/format1"
    dest: "{{checkout_dir}}"
    version: newtag
  register: update_new_tag

- name: get tags of new head
  command: git tag --contains
  args:
    chdir: "{{ checkout_dir }}"
  register: listoftags

- name: check new head
  assert:
    that:
      - update_new_tag is not changed
      - "'newtag' in listoftags.stdout_lines"


- name: clear checkout_dir
  file:
    state: absent
    path: "{{ checkout_dir }}"