lakeFS
lakeFS copied to clipboard
Fix lakectl local commits remote changes outside synced prefix
Closes #7687
Change Description
Bug Fix
The Problem
Please see the associated issue for the full description of the problem.
Root Cause
lakeFS, unlike Git, doesn't support the concept of committing only staged changes. A commit operation will commit any uncommitted diffs between the refs or fail if conflicts occur (all or nothing).
lakectl local
isn't special in this regard. However, being able to sync with any arbitrary prefix creates the expectation that any operations will be scoped to that prefix. In practice, this isn't the case. Merging a ref in lakectl local
unexpectedly merges all changes in the remote ref, regardless of prefix.
Solution
This PR adds to lakectl local commit
a check for existing uncommitted changes on the remote ref, which are outside of the synced prefix. If such changes are found, the operation is aborted and an informative error message is shown. This behavior can be overridden by adding the the --force
flag to the commit command.
Testing Details
These changes were tested manually and with unit tests included in this PR.
Note to reviewers: I believe the included tests cover the possible cases. I would like your feedback if you think that any additional tests are needed for better coverage.
Breaking Change?
This is a breaking change!
Although this behavior is unexpected and considered a bug, it will change following this PR. lakectl local
users relying on this behavior will see an error message instead of the operation completed successfully and will need to add the --force
flag to get back the previous behavior.
Special thanks to @arielshaqed for the refresher course on char
ordinals and string sort order 😅👑