Skip to content

Commit

Permalink
Change the default value of update_ref force to false (#980)
Browse files Browse the repository at this point in the history
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?

Co-authored-by: Nick Floyd <[email protected]>
Co-authored-by: Keegan Campbell <[email protected]>
3 people authored Oct 18, 2022
1 parent ddeb189 commit 8413882
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions lib/octokit/client/refs.rb
Original file line number Diff line number Diff line change
@@ -77,9 +77,7 @@ def create_ref(repo, ref, sha, options = {})
# @see https://developer.github.com/v3/git/refs/#update-a-reference
# @example Force update heads/sc/featureA for octocat/Hello-World with sha aa218f56b14c9653891f9e74264a383fa43fefbd
# Octokit.update_ref("octocat/Hello-World", "heads/sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd")
# @example Fast-forward update heads/sc/featureA for octocat/Hello-World with sha aa218f56b14c9653891f9e74264a383fa43fefbd
# Octokit.update_ref("octocat/Hello-World", "heads/sc/featureA", "aa218f56b14c9653891f9e74264a383fa43fefbd", false)
def update_ref(repo, ref, sha, force = true, options = {})
def update_ref(repo, ref, sha, force = false, options = {})
parameters = {
sha: sha,
force: force

0 comments on commit 8413882

Please sign in to comment.