Skip to content

Commit

Permalink
Fixed commiting of changes made by set-input
Browse files Browse the repository at this point in the history
Signed-off-by: Ole Herman Schumacher Elgesem <ole.elgesem@northern.tech>
  • Loading branch information
olehermanse committed Nov 22, 2022
1 parent 8b58dce commit 18530e3
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions cfbs/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from cfbs.index import _VERSION_INDEX, Index
from cfbs.git import (
is_git_repo,
git_commit,
git_get_config,
git_set_config,
git_init,
Expand Down Expand Up @@ -1067,9 +1068,21 @@ def _compare_list(a, b):
return 1

path = os.path.join(name, "input.json")
log.debug("Writing json to file '%s'" % path)
write_json(path, data)

log.debug("Comparing with data already in file '%s'" % path)
old_data = read_json(path)
if old_data == data:
log.debug("Input data for '%s' unchanged, nothing to write / commit" % name)
return 0

log.debug("Input data for '%s' changed, writing json to file '%s'" % (name, path))
write_json(path, data)
if config.get("git", False):
git_commit(
"Set the input for module '%s'" % name,
edit_commit_msg=False,
scope=[path],
)
return 0


Expand Down

0 comments on commit 18530e3

Please sign in to comment.