Fixes bug https://github.com/ansible/ansible/issues/22455 - Git reset… (#22502)
* Fixes bug https://github.com/ansible/ansible/issues/22455 - Git reset fails when file with the name 'origin' is present in the repository * #22455 Integration test for git module to test if it clones a repository with a file named origin * Fixed yaml errors for test/integration/roles/test_git_clone/tasks/main.yml * Removed the newly added target git and moved the code to test/integration/targets/git * Reorganised code structure as per comments * Fixed playbook name * Added code that didn't make it to the playbook before. * No longer need git.yml * Remove non tasks specific code from tasks file and use existing variables * Removed msg var from the vars.yml
This commit is contained in:
parent
ab8578d343
commit
1ea1becf23
3 changed files with 29 additions and 1 deletions
|
@ -816,7 +816,7 @@ def switch_version(git_path, module, dest, remote, version, verify_commit, depth
|
|||
if rc != 0:
|
||||
module.fail_json(msg="Failed to checkout branch %s" % branch,
|
||||
stdout=out, stderr=err, rc=rc)
|
||||
cmd = "%s reset --hard %s" % (git_path, remote)
|
||||
cmd = "%s reset --hard %s --" % (git_path, remote)
|
||||
else:
|
||||
# FIXME check for local_branch first, should have been fetched already
|
||||
if is_remote_branch(git_path, module, dest, remote, version):
|
||||
|
|
|
@ -29,3 +29,4 @@
|
|||
- include: checkout-new-tag.yml
|
||||
- include: tag-verification.yml
|
||||
- include: localmods.yml
|
||||
- include: reset-origin.yml
|
||||
|
|
27
test/integration/targets/git/tasks/reset-origin.yml
Normal file
27
test/integration/targets/git/tasks/reset-origin.yml
Normal file
|
@ -0,0 +1,27 @@
|
|||
---
|
||||
|
||||
- name: Clean up the directories
|
||||
file:
|
||||
state: absent
|
||||
path: "{{ item }}"
|
||||
with_items:
|
||||
- "{{ repo_dir }}/origin"
|
||||
- "{{ checkout_dir }}"
|
||||
|
||||
- name: Create a directory
|
||||
file:
|
||||
name: "{{ repo_dir }}/origin"
|
||||
state: directory
|
||||
|
||||
- name: Initialise the repo with a file named origin,see github.com/ansible/ansible/pull/22502
|
||||
shell: git init; echo "PR 22502" > origin; git add origin; git commit -m "PR 22502"
|
||||
args:
|
||||
chdir: "{{ repo_dir }}/origin"
|
||||
|
||||
- name: Clone a git repo with file named origin
|
||||
git:
|
||||
repo: "{{ repo_dir }}/origin"
|
||||
dest: "{{ checkout_dir }}"
|
||||
remote: origin
|
||||
update: no
|
||||
register: status
|
Loading…
Reference in a new issue