Skip to content

Commit

Permalink
Remove command now removes module data
Browse files Browse the repository at this point in the history
Also remove command nor writes multiline commit messages as default.

Ticket: None
Changelog: Title
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
  • Loading branch information
larsewi committed Aug 5, 2022
1 parent a514c19 commit a03a8cd
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions cfbs/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,8 @@ def _get_modules_by_url(name) -> list:
return r

num_removed = 0
msg = ""
files = []
for name in to_remove:
if name.startswith(("https://", "ssh://", "git://")):
matches = _get_modules_by_url(name)
Expand All @@ -352,25 +354,37 @@ def _get_modules_by_url(name) -> list:
if answer.lower() in ("yes", "y"):
print("Removing module '%s'" % module["name"])
modules.remove(module)
msg += "\n - Removed module '%s'" % module["name"]
num_removed += 1
else:
module = _get_module_by_name(name)
if module:
print("Removing module '%s'" % name)
modules.remove(module)
msg += "\n - Removed module '%s'" % module["name"]
num_removed += 1
else:
print("Module '%s' not found" % name)
module_data = os.path.join("./", name)
if os.path.isdir(module_data):
rm(module_data)
files.append(module_data)
log.debug("Deleted module data '%s'" % module_data)

changes_made = num_removed > 0
if num_removed > 1:
msg = "Removed %d modules\n" % num_removed + msg
else:
assert num_removed
msg = msg[4:] # Remove the '\n - ' part of the message

config.save()
if num_removed:
try:
_clean_unused_modules(config)
except CFBSReturnWithoutCommit:
pass
return 0
else:
raise CFBSReturnWithoutCommit(0)
return Result(0, changes_made, msg, files)


@commit_after_command("Cleaned unused modules")
Expand Down

0 comments on commit a03a8cd

Please sign in to comment.