feat: Add uv lock --rewrite (#15220)#19217
feat: Add uv lock --rewrite (#15220)#19217mud2monarch wants to merge 3 commits intoastral-sh:mainfrom
uv lock --rewrite (#15220)#19217Conversation
|
How does this differ from the refresh flag? |
|
Thank you! While very similar, I do think these are distinct flags. In the scenario presented by the issue, the requester has valid lockfiles and working dependencies across the team, but |
|
Ah, hmm, based on the docs, I thought that I guess #15220 is a stale issue? Feel free to close if so. I'd love an opportunity to contribute if you can identify a good first issue that is not stale. I use UV and am a big fan. |
Summary
This PR adds a new CLI flag
--rewritethat forces a re-resolution and rewrite of the lockfile even if the dependencies and requirements have not changed.Changes:
rewriteto CLI as aboolrewriteargument through tovalidate()following builder pattern ofrefreshflag (Refresh lockfile when--refreshis provided (#15991) #15994)ValidatedLock::Preferablefromvalidate()ifrewriteThis is most useful for teams who do not enforce a shared
uvversion and see large lockfile diffs that are not semantically meaningful. Closes #15220.Test Plan
lock_rewrite()modeled onlock_refresh()lock_rewrite_conflicts_locked_env()to check guarantees thatrewritedoes not coexist withlocked(other guarantees enforced byclapannotations andLockSettings::resolve())Other Qs/commentary
--rewrite? As-is, this is only available as a CLI flag. I thought I'd keep things simple for my first PR, but I can also add it.--rewriteforce a new lockfile write even if the text contents would not change at all? E.g., imagine runninguv lock --rewritetwice. I am split on the expected behavior. This PR resolves the original user's issue without this, but there may be other situations where someone really wants to blindly rewrite (e.g., they use their filesystem's timestamp to ensure freshness?), and this would be the intuitive flag to use to force that behavior.