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

Change the default value of update_ref force to false #980

Merged
merged 3 commits into from
Oct 18, 2022

Conversation

pocke
Copy link
Contributor

@pocke pocke commented Jan 22, 2018

Problem

Currently, Octokit::Client#update_ref updates a reference with force: true option. It works like git push --force.
I think the behaviour is a problem for two reasons.

Firstly, the behaviour is dangerous.
Force push destroys pushed commits sometimes. I think dangerous operations should be optional.

Secondly, the default value is false in the GitHub API.

Indicates whether to force the update or to make sure the update is a fast-forward update. Leaving this out or setting it to false will make sure you're not overwriting work. Default: false

https://developer.github.com/v3/git/refs/#update-a-reference

I think Octokit default value should be same as the GitHub API.

Note

It is a breaking change. If someone uses update_ref method without a default value and expects "force push", it will be broken.
But I think we should change default behaviour. What do you think?

Problem
====

Currently, `Octokit::Client#update_ref` updates a reference with `force: true` option. It works like `git push --force`.
I think the behaviour is a problem for two reasons.

Firstly, the behaviour is dangerous.
Force push destroys pushed commits sometimes. I think dangerous operations should be optional.

Secondly, the default value is false in the GitHub API.

> Indicates whether to force the update or to make sure the update is a fast-forward update. Leaving this out or setting it to false will make sure you're not overwriting work. Default: false
>
> https://developer.github.com/v3/git/refs/#update-a-reference

I think Octokit default value should be same as the GitHub API.

Note
===

It is a breaking change. If someone uses `update_ref` method without a default value and expects "force push", it will be broken.
But I think we should change default behaviour. What do you think?
@tarebyte
Copy link
Member

tarebyte commented Feb 1, 2018

Thanks for the PR @pocke!

I like this change, but like you said it's a breaking change to the client. So we're going to wait to 🚢 this when we start the process of releasing Octokit 5.0.

Let me know if you have any questions.

@pocke
Copy link
Contributor Author

pocke commented Feb 2, 2018

I like this change, but like you said it's a breaking change to the client. So we're going to wait to 🚢 this when we start the process of releasing Octokit 5.0.

It seems good. Thank you!

@tarebyte tarebyte changed the base branch from master to 4-stable October 19, 2020 18:40
Copy link
Member

@kfcampbell kfcampbell left a comment

Choose a reason for hiding this comment

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

I love the idea of matching the GitHub API's defaults, and we recently merged in another breaking change in #1495, so I think this is an opportune time to get this change in.

@kfcampbell kfcampbell merged commit 8413882 into octokit:main Oct 18, 2022
@pocke pocke deleted the not-force-push branch October 19, 2022 03:36
@nickfloyd nickfloyd added Type: Breaking change Used to note any change that requires a major version bump and removed breaking change labels Oct 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Breaking change Used to note any change that requires a major version bump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants