Fix git submodules path issue (#75655)

* Fix git path used for submodules

* Fix git submodules integration test
pull/75728/head
maulikd 3 years ago committed by GitHub
parent 3d081b6ca5
commit 9558f53a58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- git - Fix git path used when .git file is present (https://github.com/ansible/ansible/issues/75608).

@ -757,7 +757,8 @@ def get_repo_path(dest, bare):
if os.path.isabs(gitdir):
repo_path = gitdir
else:
repo_path = os.path.join(repo_path.split('.git')[0], gitdir)
# Use original destination directory with data from .git file.
repo_path = os.path.join(dest, gitdir)
if not os.path.isdir(repo_path):
raise ValueError('%s is not a directory' % repo_path)
return repo_path

@ -122,3 +122,29 @@
- name: SUBMODULES | Enusre submodule2 is at the appropriate commit
assert:
that: '{{ submodule2.stdout_lines | length }} == 4'
- name: SUBMODULES | clear checkout_dir
file:
state: absent
path: "{{ checkout_dir }}"
- name: SUBMODULES | Clone main submodule repository
git:
repo: "{{ repo_submodules }}"
dest: "{{ checkout_dir }}/test.gitdir"
version: 45c6c07ef10fd9e453d90207e63da1ce5bd3ae1e
recursive: yes
- name: SUBMODULES | Test that cloning submodule with .git in directory name works
git:
repo: "{{ repo_submodule1 }}"
dest: "{{ checkout_dir }}/test.gitdir/submodule1"
- name: SUBMODULES | List submodule1
command: 'ls -1a {{ checkout_dir }}/test.gitdir/submodule1'
register: submodule1
- name: SUBMODULES | Ensure submodule1 is at the appropriate commit
assert:
that: '{{ submodule1.stdout_lines | length }} == 4'

Loading…
Cancel
Save