From 06b8da85e92e5120205bb11d68efcee78bf3c90c Mon Sep 17 00:00:00 2001 From: Lukas Zapletal Date: Mon, 11 Nov 2013 12:33:13 +0100 Subject: [PATCH] Allow to merge with --ff-only option --- features/merge.feature | 21 +++++++++++++++++++++ lib/hub/commands.rb | 5 +++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/features/merge.feature b/features/merge.feature index e0a1ee3c..7ea18897 100644 --- a/features/merge.feature +++ b/features/merge.feature @@ -27,6 +27,27 @@ Feature: hub merge Add `hub merge` command """ + Scenario: Merge pull request with --ff-only option + Given the GitHub API server: + """ + require 'json' + get('/repos/defunkt/hub/pulls/164') { json \ + :head => { + :label => 'jfirebaugh:hub_merge', + :repo => {:private => false} + }, + :title => "Add `hub merge` command" + } + """ + And there is a commit named "jfirebaugh/hub_merge" + When I successfully run `hub merge --ff-only https://github.com/defunkt/hub/pull/164` + Then "git fetch git://github.com/jfirebaugh/hub.git +refs/heads/hub_merge:refs/remotes/jfirebaugh/hub_merge" should be run + When I successfully run `git show -s --format=%B` + Then the output should contain: + """ + Fast-forward (no commit created; -m option ignored) + """ + Scenario: Merge private pull request Given the GitHub API server: """ diff --git a/lib/hub/commands.rb b/lib/hub/commands.rb index dbf7817d..97b313b7 100644 --- a/lib/hub/commands.rb +++ b/lib/hub/commands.rb @@ -443,8 +443,9 @@ module Hub idx = args.index url_arg args.delete_at idx - args.insert idx, merge_head, '--no-ff', '-m', - "Merge pull request ##{pull_id} from #{merge_head}\n\n#{pull_data['title']}" + args.insert idx, merge_head, '-m', "Merge pull request ##{pull_id} from #{merge_head}\n\n#{pull_data['title']}" + idx = args.index '-m' + args.insert idx, '--no-ff' unless args.include?('--ff-only') end end -- GitLab