Skip to content

ENT-12114: Fix poor commit message when a module is removed with dependencies#305

Merged
larsewi merged 1 commit intocfengine:masterfrom
SimonThalvorsen:ENT-12114
Mar 9, 2026
Merged

ENT-12114: Fix poor commit message when a module is removed with dependencies#305
larsewi merged 1 commit intocfengine:masterfrom
SimonThalvorsen:ENT-12114

Conversation

@SimonThalvorsen
Copy link
Contributor

Ticket: ENT-12114

Copy link
Contributor

@larsewi larsewi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some nitpicks 🚀

cfbs/commands.py Outdated

num_lines = len(msg.strip().splitlines())
changes_made = num_lines > 0
dependencies = set(dependencies)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this could be a set to begin with?

cfbs/commands.py Outdated
Comment on lines +507 to +520
def _someone_needs_me(this) -> bool:
if ("added_by" not in this) or is_module_added_manually(this["added_by"]):
return True
for other in config["build"]:
if "dependencies" not in other:
continue
if this["name"] in other["dependencies"]:
return _someone_needs_me(other)
return False

tmp = [mod for mod in config["build"] if mod["name"] in dependencies]
for module in tmp:
if not _someone_needs_me(module):
deps.append(module)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code looks very familiar. Maybe you can move it outside of the function scope and reuse it?

cfbs/commands.py Outdated
"The following modules were added as dependencies but are no longer needed:"
)
for module in deps:
name = module["name"] if "name" in module else ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and on the other ones

Suggested change
name = module["name"] if "name" in module else ""
name = module.get("name", "")

…ndencies

Ticket: ENT-12114
Signed-off-by: Simon Halvorsen <simon.halvorsen@northern.tech>
Copy link
Contributor

@larsewi larsewi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 🚀

@larsewi larsewi merged commit 8b269de into cfengine:master Mar 9, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants