Skip to content

Commit 152339a

Browse files
authored
gio_mime: fix bug when looking for version (#9171)
* gio_mime: fix bug when looking for version * add changelog frag
1 parent 47637cd commit 152339a

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bugfixes:
2+
- gio_mime - fix command line when determining version of ``gio`` (https://github.com/ansible-collections/community.general/pull/9171, https://github.com/ansible-collections/community.general/issues/9158).

plugins/module_utils/gio_mime.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
def gio_mime_runner(module, **kwargs):
1313
return CmdRunner(
1414
module,
15-
command=['gio', 'mime'],
15+
command=['gio'],
1616
arg_formats=dict(
17+
mime=cmd_runner_fmt.as_fixed('mime'),
1718
mime_type=cmd_runner_fmt.as_list(),
1819
handler=cmd_runner_fmt.as_list(),
1920
version=cmd_runner_fmt.as_fixed('--version'),
@@ -29,5 +30,5 @@ def process(rc, out, err):
2930
out = out.splitlines()[0]
3031
return out.split()[-1]
3132

32-
with runner("mime_type", output_process=process) as ctx:
33+
with runner("mime mime_type", output_process=process) as ctx:
3334
return ctx.run(mime_type=mime_type)

plugins/modules/gio_mime.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,11 @@ def __init_module__(self):
108108
def __run__(self):
109109
check_mode_return = (0, 'Module executed in check mode', '')
110110
if self.vars.has_changed:
111-
with self.runner.context(args_order=["mime_type", "handler"], check_mode_skip=True, check_mode_return=check_mode_return) as ctx:
111+
with self.runner.context(args_order="mime mime_type handler", check_mode_skip=True, check_mode_return=check_mode_return) as ctx:
112112
rc, out, err = ctx.run()
113113
self.vars.stdout = out
114114
self.vars.stderr = err
115-
if self.verbosity >= 4:
116-
self.vars.run_info = ctx.run_info
115+
self.vars.set("run_info", ctx.run_info, verbosity=4)
117116

118117

119118
def main():

tests/unit/plugins/modules/test_gio_mime.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
changed: true
1414
mocks:
1515
run_command:
16-
- command: [/testbin/gio, mime, --version]
16+
- command: [/testbin/gio, --version]
1717
environ: &env-def {environ_update: {LANGUAGE: C, LC_ALL: C}, check_rc: true}
1818
rc: 0
1919
out: "2.80.0\n"
@@ -40,7 +40,7 @@
4040
skip: test helper does not support check mode yet
4141
mocks:
4242
run_command:
43-
- command: [/testbin/gio, mime, --version]
43+
- command: [/testbin/gio, --version]
4444
environ: *env-def
4545
rc: 0
4646
out: "2.80.0\n"
@@ -65,7 +65,7 @@
6565
changed: false
6666
mocks:
6767
run_command:
68-
- command: [/testbin/gio, mime, --version]
68+
- command: [/testbin/gio, --version]
6969
environ: *env-def
7070
rc: 0
7171
out: "2.80.0\n"

0 commit comments

Comments
 (0)