Skip to content

feat: implement --force flag for lock#15757

Open
11happy wants to merge 5 commits intoastral-sh:mainfrom
11happy:force_flag
Open

feat: implement --force flag for lock#15757
11happy wants to merge 5 commits intoastral-sh:mainfrom
11happy:force_flag

Conversation

@11happy
Copy link

@11happy 11happy commented Sep 9, 2025

Summary

This PR fixes #15220

Test Plan

I have tested the updated force flag working.

CC

@zanieb

// If any of the resolution-determining settings changed, invalidate the lock.
let existing_lock = if let Some(existing_lock) = existing_lock {
let existing_lock = if force {
None
Copy link
Member

@zanieb zanieb Sep 11, 2025

Choose a reason for hiding this comment

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

I think we still probably want to use the existing versions instead of ignoring the existing lockfile entirely? This might be kind of hard to teach though 🤔

I think this doesn't accomplish the goal from the issue.

@11happy
Copy link
Author

11happy commented Sep 13, 2025

Hii @zanieb
I see your point about my current implementation not addressing the core issue. To solve the issue , I am thinking to approach it like this -
For the --force flag approach:
I can set the ValidatedLock to Preferable/Versions to use existing versions but force a rewrite when --force flag is used.

OR

When validation succeeds and we reach this section:

Some(ValidatedLock::Satisfies(lock)) => {
    // Print the success message after completing resolution.
    logger.on_complete(lock.len(), start, printer)?;
    Ok(LockResult::Unchanged(lock))
}

Should I add format checking here? If there's a format mismatch (missing revision = 3, missing upload-time fields, etc.),

How should I apprach format detection ?
I saw the implementation of Lock & it has this revision field,
does checking revision field would work ?
Also is there a suggested way to detect missing upload-time fields or other format indicators?

I'd appreciate any pointers to help me move forward. Also, could you point me to resources about uv lockfile format internals?

Thanks for your patience as I work through this : )

@zanieb
Copy link
Member

zanieb commented Sep 22, 2025

I think you're on the right track with changing validation. I think we want to change

async fn validate<Context: BuildContext>(

to just immediately return Ok(Self::Preferable(lock)) if force is set. I think that should be sufficient to force us to do a new resolution and write to the lockfile?

@11happy
Copy link
Author

11happy commented Sep 22, 2025

I think you're on the right track with changing validation. I think we want to change

async fn validate<Context: BuildContext>(

to just immediately return Ok(Self::Preferable(lock)) if force is set. I think that should be sufficient to force us to do a new resolution and write to the lockfile?

Thank you, I will do it likewise : )

@11happy 11happy requested a review from zanieb September 23, 2025 14:49
@zanieb
Copy link
Member

zanieb commented Sep 23, 2025

I think you'll need to merge / rebase with the overlapping work in #15994

Signed-off-by: 11happy <soni5happy@gmail.com>
Signed-off-by: 11happy <soni5happy@gmail.com>
Signed-off-by: 11happy <soni5happy@gmail.com>
Signed-off-by: 11happy <soni5happy@gmail.com>
@11happy
Copy link
Author

11happy commented Sep 29, 2025

have rebased it, done @zanieb : )

wait let me fix CI errors & get back !

Signed-off-by: 11happy <soni5happy@gmail.com>
@11happy
Copy link
Author

11happy commented Sep 30, 2025

Hii @zanieb, I’ve fixed all the CI errors. Could you take a look when you get a chance?
Thank you : )

@11happy
Copy link
Author

11happy commented Oct 12, 2025

gentle ping !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Force newest lock file format (revision = 3, upload-time=...)

2 participants