1Feature: hub cherry-pick
2  Background:
3    Given I am in "git://github.com/rtomayko/ronn.git" git repo
4    And I am "mislav" on github.com with OAuth token "OTOKEN"
5
6  Scenario: Unchanged
7    When I run `hub cherry-pick a319d88`
8    Then the git command should be unchanged
9
10  Scenario: From GitHub commit URL
11    When I run `hub cherry-pick https://github.com/rtomayko/ronn/commit/a319d88#comments`
12    Then "git fetch -q --no-tags origin" should be run
13    And "git cherry-pick a319d88" should be run
14
15  Scenario: From GitHub pull request URL
16    When I run `hub cherry-pick https://github.com/blueyed/ronn/pull/560/commits/a319d88`
17    And "git fetch -q --no-tags origin refs/pull/560/head" should be run
18    And "git cherry-pick a319d88" should be run
19
20  Scenario: From fork that has existing remote
21    Given the "mislav" remote has url "git@github.com:mislav/ronn.git"
22    When I run `hub cherry-pick https://github.com/mislav/ronn/commit/a319d88`
23    Then "git fetch -q --no-tags mislav" should be run
24    And "git cherry-pick a319d88" should be run
25
26  Scenario: Using GitHub owner@SHA notation
27    Given the "mislav" remote has url "git@github.com:mislav/ronn.git"
28    When I run `hub cherry-pick mislav@a319d88`
29    Then "git fetch -q --no-tags mislav" should be run
30    And "git cherry-pick a319d88" should be run
31
32  Scenario: Using GitHub owner@SHA notation that is too short
33    When I run `hub cherry-pick mislav@a319`
34    Then the git command should be unchanged
35
36  Scenario: Unsupported GitHub owner/repo@SHA notation
37    When I run `hub cherry-pick mislav/ronn@a319d88`
38    Then the git command should be unchanged
39
40  Scenario: Skips processing if `-m/--mainline` is specified
41    When I run `hub cherry-pick -m 42 mislav@a319d88`
42    Then the git command should be unchanged
43    When I run `hub cherry-pick --mainline 42 mislav@a319d88`
44    Then the git command should be unchanged
45
46  Scenario: Using GitHub owner@SHA notation with remote add
47    When I run `hub cherry-pick mislav@a319d88`
48    Then "git remote add _hub-cherry-pick git://github.com/mislav/ronn.git" should be run
49    And "git fetch -q --no-tags _hub-cherry-pick" should be run
50    And "git remote rm _hub-cherry-pick" should be run
51    And "git cherry-pick a319d88" should be run
52
53  Scenario: From fork that doesn't have a remote
54    When I run `hub cherry-pick https://github.com/jingweno/ronn/commit/a319d88`
55    Then "git remote add _hub-cherry-pick git://github.com/jingweno/ronn.git" should be run
56    And "git fetch -q --no-tags _hub-cherry-pick" should be run
57    And "git remote rm _hub-cherry-pick" should be run
58    And "git cherry-pick a319d88" should be run
59