Skip to content
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

ENT-11811: cfbs recognizes and commits module input changes #193

Merged
merged 1 commit into from
May 29, 2024

Conversation

mineralsfree
Copy link
Contributor

Ticket: ENT-11811
Changelog: None
Signed-off-by: Mikita Pilinka mikita.pilinka@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.

Maybe using the os.path.samefile() function below is a more accurate way to determine if you should commit or not?

>>> import os
>>> os.path.samefile("cloud.sh", "./cloud.sh")
True

cfbs/git.py Outdated
@@ -189,7 +197,7 @@ def git_check_tracked_changes(scope=["all"]):
else:
lines = result.stdout.decode("utf-8").split("\n")
changes = [line.strip().split(" ")[1] for line in lines if line]
should_commit = any(i in changes for i in scope)
should_commit = _get_should_commit(changes, scope)
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use itertools.product() it test all the files against each other

>>> from itertools import product
>>> list(product(["1", "2", "3"], ["A", "B", "C"]))
[('1', 'A'), ('1', 'B'), ('1', 'C'), ('2', 'A'), ('2', 'B'), ('2', 'C'), ('3', 'A'), ('3', 'B'), ('3', 'C')]

E.g.,

should_commit = any(os.path.samefile(a, b) in itertools.product(changes, scope))

But what you did also OK ;)

Ticket: ENT-11811
Changelog: None
Signed-off-by: Mikita Pilinka <mikita.pilinka@northern.tech>
@olehermanse olehermanse merged commit 3d88acc into cfengine:master May 29, 2024
7 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.

3 participants