Verified Commit 35ffb0e6 authored by Karel Koci's avatar Karel Koci 🤘
Browse files

Remove need_approval file if plan is clean

There is possible situation when we generated approval plan and then
disabled approvals which leads to update to pass. When we reactivate
approvals it is reported as new plan to approve, but there is no such
change planned, it's just a ghost of old plan. This ensures that we
remove plan when we have no new plan.
parent 496e4b8d
Pipeline #17911 passed with stages
in 15 minutes
......@@ -99,6 +99,12 @@ static bool approved(struct interpreter *interpreter, const char *approval_file,
return false;
static void approval_clean(const char *approval_file) {
if (approval_file)
// Ignore errors as there might be no file which is valid
static const char *time_load(void) {
static char timebuf[18]; // "YYYY-MM-DD HH:mm\t\0"
time_t tm = time(NULL);
......@@ -240,16 +246,15 @@ int main(int argc, char *argv[]) {
ASSERT_MSG(result_count == 1, "Wrong number of results of transaction.empty");
bool trans_empty;
ASSERT_MSG(interpreter_collect_results(interpreter, "b", &trans_empty) == -1, "The result of transaction.empty is not bool");
if (trans_empty)
if (trans_empty) {
approval_clean(approval_file); // There is nothing to do and if we have approvals enabled we should drop approval file
if (!batch) {
// For now we want to confirm by the user.
fprintf(stderr, "Press return to continue, CTRL+C to abort\n");
if (approval_file)
// If there is any approval_file we just approved it so remove any
// file. Also ignore errors as there might be none.
approval_clean(approval_file); // If there is any approval_file we just approved it so remove it.
} else if (!approved(interpreter, approval_file, approvals, approval_count))
// Approvals are only for non-interactive mode (implied by batch mode).
// Otherwise user approves on terminal in previous code block.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment