Repository navigation
Keep an in-project encryption key usable when push renames the project - #762
Conversation
The remapping of a path inside a renamed project now lives next to rename_project_and_contents, so every caller that renames a project can reuse it. Covers an explicit --key inside the project and a configured key outside the project, which keeps its path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Approving. When a push renames the project directory, a key inside it, whether set in encryption-key-path or given with --key, is now found at its new location. Keys outside the project keep their path. The two push tests for a key inside the project fail with master's push_manager.py and pass here. The pull side is left to #761.
I set risk:low: the change is small and easy to revert, the paths that work today behave as before, and it has tests that reproduce the failure, green CI and an end-to-end run.
There was a problem hiding this comment.
Approving. Independently tested end to end: a cloud-assigned rename preserves configured keys, explicit --encrypt --key and --decrypt --key, with the expected uploaded content and cloud encryption state. Outside-project keys remain usable. The three in-project cases fail on master with the old key path.
PYTHONPATH="$PWD" python -m pytest -q: 2900 passed, 81 skipped. Static analysis passed.
Closes #742
Description
When
lean cloud pushrenames a project directory (its name is invalid locally, or the cloud returns a different name on creation), a key file stored inside the project moves with the directory, but the push kept using the old path, both fromencryption-key-pathand from an explicit--key. The push then failed withNo such file or directorybefore uploading anything.After the rename,
PushManager._push_projectnow maps a key path inside the old project directory to the new one, and updatesencryption-key-pathin the project config. Keys outside the project directory keep their path, and pushes that don't rename are unchanged.The mapping is
ProjectManager.get_path_after_project_rename, next torename_project_and_contents, so the other caller that renames projects can reuse it:lean cloud pullhas the same problem, tracked in #761 and left out of this change.The first commit is cherry-picked from #753 (author kept); the second moves its helper into
ProjectManagerand adds tests.Testing
masterand pass here:test_cloud_push_follows_encryption_key_inside_project_when_push_renames_project(configured key)test_cloud_push_follows_given_encryption_key_inside_project_when_push_renames_project(--encrypt --key)test_cloud_push_keeps_encryption_key_path_outside_project_when_push_renames_project, plustest_get_path_after_project_rename_*for paths inside and outside the project (including a siblingOld Project 2) and relative paths.python -m pytest -rs: 2899 passed, 81 skipped, 1 failed. The failure istests/ui/test_app.py::test_command_process_runs_the_cli_as_a_child_process, which fails the same way onmasterin my environment: the child process imported an installedlean 1.0.234instead of the checkout.python static_analysis.py: passed.master: the directory was renamed, thenCannot push '...': [Errno 2] No such file or directory: '<old dir>/key.txt', and the project's files were never uploaded.main.pyis the local ciphertext, andencryption-key-pathnames the renamed directory. A push with an explicit--encrypt --keyinside the project also succeeded and left the cloud project encrypted with that key.