mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* fixed bug
- scope file was not working
- added test to guarantee that behaviour
- marked integration test as destructive, because it overwrites ~/.gitconfig
* added changelog fragment
* Update tests/integration/targets/git_config/tasks/setup_no_value.yml
Co-authored-by: Felix Fontein <felix@fontein.de>
* Update tests/integration/targets/git_config/tasks/get_set_state_present_file.yml
Co-authored-by: Felix Fontein <felix@fontein.de>
* Update tests/integration/targets/git_config/tasks/get_set_state_present_file.yml
Co-authored-by: Felix Fontein <felix@fontein.de>
* Update tests/integration/targets/git_config/aliases
Co-authored-by: Felix Fontein <felix@fontein.de>
* Update changelogs/fragments/2125-git-config-scope-file.yml
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit eb24e33666
)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
0d28bfb67e
commit
1cef1359d0
7 changed files with 50 additions and 7 deletions
2
changelogs/fragments/2125-git-config-scope-file.yml
Normal file
2
changelogs/fragments/2125-git-config-scope-file.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- git_config - fixed scope ``file`` behaviour and added integraton test for it (https://github.com/ansible-collections/community.general/issues/2117).
|
|
@ -216,14 +216,13 @@ def main():
|
||||||
args = [git_path, "config", "--includes"]
|
args = [git_path, "config", "--includes"]
|
||||||
if params['list_all']:
|
if params['list_all']:
|
||||||
args.append('-l')
|
args.append('-l')
|
||||||
if scope:
|
|
||||||
args.append("--" + scope)
|
|
||||||
if name:
|
|
||||||
args.append(name)
|
|
||||||
|
|
||||||
if scope == 'file':
|
if scope == 'file':
|
||||||
args.append('-f')
|
args.append('-f')
|
||||||
args.append(params['file'])
|
args.append(params['file'])
|
||||||
|
elif scope:
|
||||||
|
args.append("--" + scope)
|
||||||
|
if name:
|
||||||
|
args.append(name)
|
||||||
|
|
||||||
if scope == 'local':
|
if scope == 'local':
|
||||||
dir = params['repo']
|
dir = params['repo']
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
shippable/posix/group3
|
shippable/posix/group3
|
||||||
skip/aix
|
skip/aix
|
||||||
|
destructive
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
---
|
||||||
|
- import_tasks: setup_no_value.yml
|
||||||
|
|
||||||
|
- name: setting value with state=present
|
||||||
|
git_config:
|
||||||
|
name: "{{ option_name }}"
|
||||||
|
value: "{{ option_value }}"
|
||||||
|
scope: "file"
|
||||||
|
file: "{{ output_dir }}/gitconfig_file"
|
||||||
|
state: present
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- name: getting value with state=present
|
||||||
|
git_config:
|
||||||
|
name: "{{ option_name }}"
|
||||||
|
scope: "file"
|
||||||
|
file: "{{ output_dir }}/gitconfig_file"
|
||||||
|
state: present
|
||||||
|
register: get_result
|
||||||
|
|
||||||
|
- name: assert set changed and value is correct with state=present
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- set_result is changed
|
||||||
|
- set_result.diff.before == "\n"
|
||||||
|
- set_result.diff.after == option_value + "\n"
|
||||||
|
- get_result is not changed
|
||||||
|
- get_result.config_value == option_value
|
||||||
|
...
|
|
@ -16,6 +16,8 @@
|
||||||
- import_tasks: get_set_no_state.yml
|
- import_tasks: get_set_no_state.yml
|
||||||
# testing get/set option with state=present
|
# testing get/set option with state=present
|
||||||
- import_tasks: get_set_state_present.yml
|
- import_tasks: get_set_state_present.yml
|
||||||
|
# testing get/set option with state=present and scope=file
|
||||||
|
- import_tasks: get_set_state_present_file.yml
|
||||||
# testing state=absent without value to delete
|
# testing state=absent without value to delete
|
||||||
- import_tasks: unset_no_value.yml
|
- import_tasks: unset_no_value.yml
|
||||||
# testing state=absent with value to delete
|
# testing state=absent with value to delete
|
||||||
|
|
|
@ -5,4 +5,9 @@
|
||||||
file:
|
file:
|
||||||
path: ~/.gitconfig
|
path: ~/.gitconfig
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
|
- name: set up without value (file)
|
||||||
|
file:
|
||||||
|
path: "{{ output_dir }}/gitconfig_file"
|
||||||
|
state: absent
|
||||||
...
|
...
|
|
@ -5,4 +5,9 @@
|
||||||
copy:
|
copy:
|
||||||
src: gitconfig
|
src: gitconfig
|
||||||
dest: ~/.gitconfig
|
dest: ~/.gitconfig
|
||||||
|
|
||||||
|
- name: set up with value (file)
|
||||||
|
copy:
|
||||||
|
src: gitconfig
|
||||||
|
dest: "{{ output_dir }}/gitconfig_file"
|
||||||
...
|
...
|
Loading…
Reference in a new issue