From 5a4f60dc0338dd4d20c8a355a7878b4f9eadd6db Mon Sep 17 00:00:00 2001 From: simonLeary42 <71396965+simonLeary42@users.noreply.github.com> Date: Wed, 20 May 2026 07:49:00 -0400 Subject: [PATCH] git: remove redundant error checking (#86937) * remove redundant error checking that makes bad error message Co-authored-by: Sloane Hertel <19572925+s-hertel@users.noreply.github.com> --- changelogs/fragments/86937-git-rm-redundant-err-checks.yml | 2 ++ lib/ansible/modules/git.py | 5 ----- 2 files changed, 2 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/86937-git-rm-redundant-err-checks.yml diff --git a/changelogs/fragments/86937-git-rm-redundant-err-checks.yml b/changelogs/fragments/86937-git-rm-redundant-err-checks.yml new file mode 100644 index 00000000000..44858e40caf --- /dev/null +++ b/changelogs/fragments/86937-git-rm-redundant-err-checks.yml @@ -0,0 +1,2 @@ +bugfixes: + - git - remove redundant error checks after `run_command(check_rc=True)` diff --git a/lib/ansible/modules/git.py b/lib/ansible/modules/git.py index 7d80d92fdc3..2837e1a346c 100644 --- a/lib/ansible/modules/git.py +++ b/lib/ansible/modules/git.py @@ -994,9 +994,6 @@ def submodules_fetch(git_path, module, remote, track_submodules, dest): begin = get_submodule_versions(git_path, module, dest) cmd = [git_path, 'submodule', 'foreach', git_path, 'fetch'] (rc, out, err) = module.run_command(cmd, check_rc=True, cwd=dest) - if rc != 0: - module.fail_json(msg="Failed to fetch submodules: %s" % out + err) - if track_submodules: # Compare each submodule against its configured remote branch after = {} @@ -1017,8 +1014,6 @@ def submodules_fetch(git_path, module, remote, track_submodules, dest): # Compare against the superproject's expectation cmd = [git_path, 'submodule', 'status'] (rc, out, err) = module.run_command(cmd, check_rc=True, cwd=dest) - if rc != 0: - module.fail_json(msg='Failed to retrieve submodule status: %s' % out + err) for line in out.splitlines(): if line[0] != ' ': changed = True