From 7acc3eb76e76d4781507ddaec0da237df6956397 Mon Sep 17 00:00:00 2001 From: Masataka Pocke Kuwabara Date: Mon, 22 Jan 2018 13:32:00 +0900 Subject: [PATCH] Change the default value of `update_ref` `force` to false 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? --- lib/octokit/client/refs.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/octokit/client/refs.rb b/lib/octokit/client/refs.rb index c464eed9b..efaffa4bc 100644 --- a/lib/octokit/client/refs.rb +++ b/lib/octokit/client/refs.rb @@ -65,7 +65,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") - def update_ref(repo, ref, sha, force = true, options = {}) + def update_ref(repo, ref, sha, force = false, options = {}) parameters = { :sha => sha, :force => force