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

proposing conan lock bundle clean-modified command #8726

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions conans/client/command.py
Expand Up @@ -1924,6 +1924,10 @@ def lock(self, *args):
update_bundle_cmd = bundle_subparsers.add_parser('update', help=update_help)
update_bundle_cmd.add_argument('bundle', help='Path to lockfile bundle')

clean_modified_bundle_cmd = bundle_subparsers.add_parser('clean-modified',
help='Clean modified flag')
clean_modified_bundle_cmd.add_argument('bundle', help='Path to lockfile bundle')

args = parser.parse_args(*args)
self._warn_python_version()

Expand All @@ -1934,6 +1938,8 @@ def lock(self, *args):
self._conan.lock_bundle_create(args.lockfiles, args.bundle_out)
elif args.bundlecommand == "update":
self._conan.lock_bundle_update(args.bundle)
elif args.bundlecommand == "clean-modified":
self._conan.lock_bundle_clean_modified(args.bundle)
elif args.bundlecommand == "build-order":
build_order = self._conan.lock_bundle_build_order(args.bundle)
self._out.writeln(build_order)
Expand Down
7 changes: 7 additions & 0 deletions conans/client/conan_api.py
Expand Up @@ -1367,6 +1367,13 @@ def lock_bundle_update(self, lock_bundle_path, cwd=None):
revisions_enabled = self.app.cache.config.revisions_enabled
LockBundle.update_bundle(lock_bundle_path, revisions_enabled)

@api_method
def lock_bundle_clean_modified(self, lock_bundle_path, cwd=None):
cwd = cwd or os.getcwd()
lock_bundle_path = _make_abs_path(lock_bundle_path, cwd)
revisions_enabled = self.app.cache.config.revisions_enabled
LockBundle.clean_modified(lock_bundle_path, revisions_enabled)

@api_method
def lock_create(self, path, lockfile_out,
reference=None, name=None, version=None, user=None, channel=None,
Expand Down
15 changes: 15 additions & 0 deletions conans/model/lock_bundle.py
Expand Up @@ -161,3 +161,18 @@ def update_bundle(bundle_path, revisions_enabled):
graph_lock_conf.save(lockfile)

save(bundle_path, bundle.dumps())

@staticmethod
def clean_modified(bundle_path, revisions_enabled):
bundle = LockBundle()
bundle.loads(load(bundle_path))
for node in bundle._nodes.values():
for pkg in node["packages"]:
pkg["modified"] = None

for lockfile, nodes_ids in pkg["lockfiles"].items():
graph_lock_conf = GraphLockFile.load(lockfile, revisions_enabled)
graph_lock_conf.graph_lock.clean_modified()
graph_lock_conf.save(lockfile)

save(bundle_path, bundle.dumps())
8 changes: 8 additions & 0 deletions conans/test/integration/graph_lock/test_lock_bundle.py
Expand Up @@ -103,6 +103,14 @@ def test_basic():
assert nodes["3"].package_id == "cb054d0b3e1ca595dc66bc2339d40f1f8f04ab31"
assert nodes["3"].prev == "9e99cfd92d0d7df79d687b01512ce844"

client.run("lock bundle clean-modified lock1.bundle")
bundle = client.load("lock1.bundle")
assert '"modified": true' not in bundle
lock1 = client.load("app1_windows.lock")
assert '"modified": true' not in lock1
lock2 = client.load("app2_linux.lock")
assert '"modified": true' not in lock2


def test_build_requires():
client = TestClient()
Expand Down