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

Use --force-with-lease instead of --force on git push #11590

Closed
herndlm opened this issue Sep 6, 2021 · 6 comments · Fixed by #11754
Closed

Use --force-with-lease instead of --force on git push #11590

herndlm opened this issue Sep 6, 2021 · 6 comments · Fixed by #11754
Labels
priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others type:feature Feature (new functionality)

Comments

@herndlm
Copy link
Contributor

herndlm commented Sep 6, 2021

What would you like Renovate to be able to do?

I have renovate running with :rebaseStalePrs to keep branches updated and today I managed to work at a branch the same time as renovate did. Apparently I finished my work before the bot and I was using --force-with-lease which was working fine. Then the bot finished it's work too using --force which overwrote my work. When I was checking the PR I was confused for a good minute and tried to figure out where my changes went.

I guess this is pretty rare to happen, but I suggest that renovate uses --force-with-lease instead to prevent exactly what I described. In that case the push should be safer and fail if the remote ref is not the expected value (most likely because somebody edited it inbetween). See also https://git-scm.com/docs/git-push#Documentation/git-push.txt---no-force-with-lease

If you have any ideas on how this should be implemented, please tell us here.

If I'm not mistaken, it should be as simple as replacing --force with --force-with-lease in https://github.com/renovatebot/renovate/blob/26.19.1/lib/util/git/index.ts#L804

Is this a feature you are interested in implementing yourself?

Yes

@herndlm herndlm added priority-5-triage status:requirements Full requirements are not yet known, so implementation should not be started type:feature Feature (new functionality) labels Sep 6, 2021
@herndlm
Copy link
Contributor Author

herndlm commented Sep 8, 2021

I tried implementing this but failed miserably to keep the tests green.

Apparently in the bare checkout (https://github.com/renovatebot/renovate/blob/26.19.1/lib/util/git/index.spec.ts#L71) using --force-with-lease always fails, while a simple --forcewould still work.

Removing --bare "fixes" that but then other tests fail.

I don't know enough about git bare repos yet I guess, I might take another look next week or so.

@rarkins
Copy link
Collaborator

rarkins commented Sep 8, 2021

It might be easier once I merge and verify #11401

@HonkingGoose
Copy link
Collaborator

@herndlm PR #11401 is now merged, so maybe implementing this feature will be easier for you now? 😉

@herndlm
Copy link
Contributor Author

herndlm commented Sep 12, 2021

Thx, I saw. I'll continue this week :)

@HonkingGoose
Copy link
Collaborator

Thx, I saw. I'll continue this week :)

I've assigned this issue to you, so that we - and others - can see you're going to work on the feature. 😉

@HonkingGoose HonkingGoose added status:ready priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others and removed status:requirements Full requirements are not yet known, so implementation should not be started priority-5-triage labels Sep 12, 2021
@renovate-release
Copy link
Collaborator

🎉 This issue has been resolved in version 27.22.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 31, 2021
@herndlm herndlm removed their assignment Feb 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
priority-3-medium Default priority, "should be done" but isn't prioritised ahead of others type:feature Feature (new functionality)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants