-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CFE-4081: Fixed commiting of changes made by set-input #144
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
|
@@ -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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No interactivity here and prompting the user if they want to modify the commit message? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, I am submitting some changes which should explain / clear this up. (In a follow-up). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WIP: #145 |
||
scope=[path], | ||
) | ||
return 0 | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,3 +40,12 @@ echo '[ | |
"while": "Specify another file you want deleted on your hosts?" | ||
} | ||
]' | cfbs --log=debug set-input delete-files - | ||
|
||
# Error if the file has never been added: | ||
git ls-files --error-unmatch delete-files/input.json | ||
|
||
# Error if there are staged (added, not yet commited) | ||
git diff --exit-code --staged | ||
|
||
# Error if there are uncommited changes (to tracked files): | ||
git diff --exit-code | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like these checks should be in a nicely-named function in some shared bash source. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep, good idea |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should, ideally, be done before the more expensive checks/comparison above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking it makes sense to always do the expensive checks (validation), even if the (potentially bad) data is already there.