mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
fix insertion of newfile key in changes dict for windows
This commit is contained in:
parent
00292d6b0d
commit
0d518807e2
3 changed files with 9 additions and 8 deletions
|
@ -5755,7 +5755,7 @@ def check_managed_changes(
|
|||
If ``True``, creation of new files will still show a diff in the
|
||||
changes return.
|
||||
|
||||
.. versionadded:: 3007.0
|
||||
.. versionadded:: 3008.0
|
||||
|
||||
CLI Example:
|
||||
|
||||
|
@ -5976,7 +5976,7 @@ def check_file_meta(
|
|||
If ``True``, creation of new files will still show a diff in the
|
||||
changes return.
|
||||
|
||||
.. versionadded:: 3007.0
|
||||
.. versionadded:: 3008.0
|
||||
"""
|
||||
changes = {}
|
||||
has_changes = False
|
||||
|
@ -6587,7 +6587,7 @@ def manage_file(
|
|||
If ``True``, creation of new files will still show a diff in the
|
||||
changes return.
|
||||
|
||||
.. versionadded:: 3007.0
|
||||
.. versionadded:: 3008.0
|
||||
|
||||
CLI Example:
|
||||
|
||||
|
|
|
@ -3021,7 +3021,7 @@ def managed(
|
|||
If ``True``, creation of new files will still show a diff in the
|
||||
changes return.
|
||||
|
||||
.. versionadded:: 3007.0
|
||||
.. versionadded:: 3008.0
|
||||
"""
|
||||
if "env" in kwargs:
|
||||
# "env" is not supported; Use "saltenv".
|
||||
|
@ -3370,9 +3370,11 @@ def managed(
|
|||
reset=win_perms_reset,
|
||||
)
|
||||
except CommandExecutionError as exc:
|
||||
if not isinstance(
|
||||
ret["changes"], tuple
|
||||
) and exc.strerror.startswith("Path not found"):
|
||||
if (
|
||||
not isinstance(ret["changes"], tuple)
|
||||
and exc.strerror.startswith("Path not found")
|
||||
and not new_file_diff
|
||||
):
|
||||
ret["changes"]["newfile"] = name
|
||||
|
||||
if isinstance(ret["changes"], tuple):
|
||||
|
|
|
@ -1050,7 +1050,6 @@ def test_file_managed_new_file_diff(file, tmp_path):
|
|||
ret = file.managed(str(name), contents="EITR", new_file_diff=True, test=True)
|
||||
assert ret.changes == {
|
||||
"diff": f"--- \n+++ \n@@ -0,0 +1 @@\n+EITR{os.linesep}",
|
||||
"newfile": str(name),
|
||||
}
|
||||
assert not name.exists()
|
||||
ret = file.managed(str(name), contents="EITR", new_file_diff=True)
|
||||
|
|
Loading…
Add table
Reference in a new issue