2017-01-06 22:38:53 +00:00
|
|
|
# test change of repo url
|
|
|
|
# see https://github.com/ansible/ansible-modules-core/pull/721
|
|
|
|
|
2017-10-13 14:30:15 +00:00
|
|
|
- name: CHANGE-REPO-URL | clear checkout_dir
|
|
|
|
file:
|
|
|
|
state: absent
|
|
|
|
path: "{{ checkout_dir }}"
|
2017-01-06 22:38:53 +00:00
|
|
|
|
2017-10-13 14:30:15 +00:00
|
|
|
- name: CHANGE-REPO-URL | Clone example git repo
|
2017-01-06 22:38:53 +00:00
|
|
|
git:
|
2017-10-13 14:30:15 +00:00
|
|
|
repo: "{{ repo_update_url_1 }}"
|
|
|
|
dest: "{{ checkout_dir }}"
|
2017-01-06 22:38:53 +00:00
|
|
|
|
2017-10-13 14:30:15 +00:00
|
|
|
- name: CHANGE-REPO-URL | Clone repo with changed url to the same place
|
2017-01-06 22:38:53 +00:00
|
|
|
git:
|
2017-10-13 14:30:15 +00:00
|
|
|
repo: "{{ repo_update_url_2 }}"
|
|
|
|
dest: "{{ checkout_dir }}"
|
2017-01-06 22:38:53 +00:00
|
|
|
register: clone2
|
|
|
|
|
|
|
|
- assert:
|
2017-11-27 22:58:08 +00:00
|
|
|
that: "clone2 is successful"
|
2017-01-06 22:38:53 +00:00
|
|
|
|
2017-10-13 14:30:15 +00:00
|
|
|
- name: CHANGE-REPO-URL | check url updated
|
2017-01-06 22:38:53 +00:00
|
|
|
shell: git remote show origin | grep Fetch
|
|
|
|
register: remote_url
|
|
|
|
args:
|
2017-10-13 14:30:15 +00:00
|
|
|
chdir: "{{ checkout_dir }}"
|
2017-01-06 22:38:53 +00:00
|
|
|
environment:
|
|
|
|
LC_ALL: C
|
|
|
|
|
|
|
|
- assert:
|
2017-10-13 14:30:15 +00:00
|
|
|
that:
|
2017-01-06 22:38:53 +00:00
|
|
|
- "'git-test-new' in remote_url.stdout"
|
|
|
|
- "'git-test-old' not in remote_url.stdout"
|
|
|
|
|
2017-10-13 14:30:15 +00:00
|
|
|
- name: CHANGE-REPO-URL | check for new content in git-test-new
|
2017-01-06 22:38:53 +00:00
|
|
|
stat: path={{ checkout_dir }}/newfilename
|
|
|
|
register: repo_content
|
|
|
|
|
2017-10-13 14:30:15 +00:00
|
|
|
- name: CHANGE-REPO-URL | assert presence of new file in repo (i.e. working copy updated)
|
2017-01-06 22:38:53 +00:00
|
|
|
assert:
|
|
|
|
that: "repo_content.stat.exists"
|
|
|
|
|
|
|
|
# Make sure 'changed' result is accurate in check mode.
|
|
|
|
# See https://github.com/ansible/ansible-modules-core/pull/4243
|
|
|
|
|
2017-10-13 14:30:15 +00:00
|
|
|
- name: CHANGE-REPO-URL | clear checkout_dir
|
|
|
|
file:
|
|
|
|
state: absent
|
|
|
|
path: "{{ checkout_dir }}"
|
2017-01-06 22:38:53 +00:00
|
|
|
|
2017-10-13 14:30:15 +00:00
|
|
|
- name: CHANGE-REPO-URL | clone repo
|
|
|
|
git:
|
|
|
|
repo: "{{ repo_update_url_1 }}"
|
|
|
|
dest: "{{ checkout_dir }}"
|
2017-01-06 22:38:53 +00:00
|
|
|
|
2017-10-13 14:30:15 +00:00
|
|
|
- name: CHANGE-REPO-URL | clone repo with same url to same destination
|
|
|
|
git:
|
|
|
|
repo: "{{ repo_update_url_1 }}"
|
|
|
|
dest: "{{ checkout_dir }}"
|
2017-01-06 22:38:53 +00:00
|
|
|
register: checkout_same_url
|
|
|
|
|
2017-10-13 14:30:15 +00:00
|
|
|
- name: CHANGE-REPO-URL | check repo not changed
|
2017-01-06 22:38:53 +00:00
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- checkout_same_url is not changed
|
2017-01-06 22:38:53 +00:00
|
|
|
|
|
|
|
|
2017-10-13 14:30:15 +00:00
|
|
|
- name: CHANGE-REPO-URL | clone repo with new url to same destination
|
|
|
|
git:
|
|
|
|
repo: "{{ repo_update_url_2 }}"
|
|
|
|
dest: "{{ checkout_dir }}"
|
2017-01-06 22:38:53 +00:00
|
|
|
register: checkout_new_url
|
|
|
|
|
2017-10-13 14:30:15 +00:00
|
|
|
- name: CHANGE-REPO-URL | check repo changed
|
2017-01-06 22:38:53 +00:00
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- checkout_new_url is changed
|
2017-01-06 22:38:53 +00:00
|
|
|
|
|
|
|
|
2017-10-13 14:30:15 +00:00
|
|
|
- name: CHANGE-REPO-URL | clone repo with new url in check mode
|
|
|
|
git:
|
|
|
|
repo: "{{ repo_update_url_1 }}"
|
|
|
|
dest: "{{ checkout_dir }}"
|
2017-01-06 22:38:53 +00:00
|
|
|
register: checkout_new_url_check_mode
|
|
|
|
check_mode: True
|
|
|
|
|
2017-10-13 14:30:15 +00:00
|
|
|
- name: CHANGE-REPO-URL | check repo reported changed in check mode
|
2017-01-06 22:38:53 +00:00
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- checkout_new_url_check_mode is changed
|
|
|
|
when: git_version.stdout is version(git_version_supporting_ls_remote, '>=')
|
2017-01-06 22:38:53 +00:00
|
|
|
|
2017-10-13 14:30:15 +00:00
|
|
|
- name: CHANGE-REPO-URL | clone repo with new url after check mode
|
|
|
|
git:
|
|
|
|
repo: "{{ repo_update_url_1 }}"
|
|
|
|
dest: "{{ checkout_dir }}"
|
2017-01-06 22:38:53 +00:00
|
|
|
register: checkout_new_url_after_check_mode
|
|
|
|
|
2017-10-13 14:30:15 +00:00
|
|
|
- name: CHANGE-REPO-URL | check repo still changed after check mode
|
2017-01-06 22:38:53 +00:00
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 22:58:08 +00:00
|
|
|
- checkout_new_url_after_check_mode is changed
|
2017-01-06 22:38:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Test that checkout by branch works when the branch is not in our current repo but the sha is
|
|
|
|
|
2017-10-13 14:30:15 +00:00
|
|
|
- name: CHANGE-REPO-URL | clear checkout_dir
|
|
|
|
file:
|
|
|
|
state: absent
|
|
|
|
path: "{{ checkout_dir }}"
|
2017-01-06 22:38:53 +00:00
|
|
|
|
2017-10-13 14:30:15 +00:00
|
|
|
- name: CHANGE-REPO-URL | "Clone example git repo that we're going to modify"
|
2017-01-06 22:38:53 +00:00
|
|
|
git:
|
2017-10-13 14:30:15 +00:00
|
|
|
repo: "{{ repo_update_url_1 }}"
|
|
|
|
dest: "{{ checkout_dir }}/repo"
|
2017-01-06 22:38:53 +00:00
|
|
|
|
2017-10-13 14:30:15 +00:00
|
|
|
- name: CHANGE-REPO-URL | Clone the repo again - this is what we test
|
2017-01-06 22:38:53 +00:00
|
|
|
git:
|
2017-10-13 14:30:15 +00:00
|
|
|
repo: "{{ checkout_dir }}/repo"
|
|
|
|
dest: "{{ checkout_dir }}/checkout"
|
2017-01-06 22:38:53 +00:00
|
|
|
|
2017-10-13 14:30:15 +00:00
|
|
|
- name: CHANGE-REPO-URL | Add a branch to the repo
|
2017-01-06 22:38:53 +00:00
|
|
|
command: git branch new-branch
|
|
|
|
args:
|
2017-10-13 14:30:15 +00:00
|
|
|
chdir: "{{ checkout_dir }}/repo"
|
2017-01-06 22:38:53 +00:00
|
|
|
|
2017-10-13 14:30:15 +00:00
|
|
|
- name: CHANGE-REPO-URL | Checkout the new branch in the checkout
|
2017-01-06 22:38:53 +00:00
|
|
|
git:
|
2017-10-13 14:30:15 +00:00
|
|
|
repo: "{{ checkout_dir}}/repo"
|
2017-01-06 22:38:53 +00:00
|
|
|
version: 'new-branch'
|
2017-10-13 14:30:15 +00:00
|
|
|
dest: "{{ checkout_dir }}/checkout"
|