|
| 1 | +Feature: hub pr merge |
| 2 | + Background: |
| 3 | + Given I am in "git://github.com/friederbluemle/hub.git" git repo |
| 4 | + And I am "friederbluemle" on github.com with OAuth token "OTOKEN" |
| 5 | + |
| 6 | + Scenario: Default merge |
| 7 | + Given the GitHub API server: |
| 8 | + """ |
| 9 | + put('/repos/friederbluemle/hub/pulls/12/merge'){ |
| 10 | + assert :merge_method => "merge", |
| 11 | + :commit_title => :no, |
| 12 | + :commit_message => :no, |
| 13 | + :sha => :no |
| 14 | +
|
| 15 | + json :merged => true, |
| 16 | + :sha => "MERGESHA", |
| 17 | + :message => "All done!" |
| 18 | + } |
| 19 | + """ |
| 20 | + When I successfully run `hub pr merge 12` |
| 21 | + Then the output should contain exactly "" |
| 22 | + |
| 23 | + Scenario: Squash merge |
| 24 | + Given the GitHub API server: |
| 25 | + """ |
| 26 | + put('/repos/friederbluemle/hub/pulls/12/merge'){ |
| 27 | + assert :merge_method => "squash", |
| 28 | + :commit_title => :no, |
| 29 | + :commit_message => :no, |
| 30 | + :sha => :no |
| 31 | +
|
| 32 | + json :merged => true, |
| 33 | + :sha => "MERGESHA", |
| 34 | + :message => "All done!" |
| 35 | + } |
| 36 | + """ |
| 37 | + When I successfully run `hub pr merge --squash 12` |
| 38 | + Then the output should contain exactly "" |
| 39 | + |
| 40 | + Scenario: Merge with rebase |
| 41 | + Given the GitHub API server: |
| 42 | + """ |
| 43 | + put('/repos/friederbluemle/hub/pulls/12/merge'){ |
| 44 | + assert :merge_method => "rebase", |
| 45 | + :commit_title => :no, |
| 46 | + :commit_message => :no, |
| 47 | + :sha => :no |
| 48 | +
|
| 49 | + json :merged => true, |
| 50 | + :sha => "MERGESHA", |
| 51 | + :message => "All done!" |
| 52 | + } |
| 53 | + """ |
| 54 | + When I successfully run `hub pr merge --rebase 12` |
| 55 | + Then the output should contain exactly "" |
| 56 | + |
| 57 | + Scenario: Merge with title |
| 58 | + Given the GitHub API server: |
| 59 | + """ |
| 60 | + put('/repos/friederbluemle/hub/pulls/12/merge'){ |
| 61 | + assert :commit_title => "mytitle", |
| 62 | + :commit_message => "" |
| 63 | +
|
| 64 | + json :merged => true, |
| 65 | + :sha => "MERGESHA", |
| 66 | + :message => "All done!" |
| 67 | + } |
| 68 | + """ |
| 69 | + When I successfully run `hub pr merge 12 -m mytitle` |
| 70 | + Then the output should contain exactly "" |
| 71 | + |
| 72 | + Scenario: Merge with title and body |
| 73 | + Given the GitHub API server: |
| 74 | + """ |
| 75 | + put('/repos/friederbluemle/hub/pulls/12/merge'){ |
| 76 | + assert :commit_title => "mytitle", |
| 77 | + :commit_message => "msg1\n\nmsg2" |
| 78 | +
|
| 79 | + json :merged => true, |
| 80 | + :sha => "MERGESHA", |
| 81 | + :message => "All done!" |
| 82 | + } |
| 83 | + """ |
| 84 | + When I successfully run `hub pr merge 12 -m mytitle -m msg1 -m msg2` |
| 85 | + Then the output should contain exactly "" |
| 86 | + |
| 87 | + Scenario: Merge with title and body from file |
| 88 | + Given a file named "msg.txt" with: |
| 89 | + """ |
| 90 | + mytitle |
| 91 | +
|
| 92 | + msg1 |
| 93 | +
|
| 94 | + msg2 |
| 95 | + """ |
| 96 | + Given the GitHub API server: |
| 97 | + """ |
| 98 | + put('/repos/friederbluemle/hub/pulls/12/merge'){ |
| 99 | + assert :commit_title => "mytitle", |
| 100 | + :commit_message => "msg1\n\nmsg2" |
| 101 | +
|
| 102 | + json :merged => true, |
| 103 | + :sha => "MERGESHA", |
| 104 | + :message => "All done!" |
| 105 | + } |
| 106 | + """ |
| 107 | + When I successfully run `hub pr merge 12 -F msg.txt` |
| 108 | + Then the output should contain exactly "" |
| 109 | + |
| 110 | + Scenario: Merge with head SHA |
| 111 | + Given the GitHub API server: |
| 112 | + """ |
| 113 | + put('/repos/friederbluemle/hub/pulls/12/merge'){ |
| 114 | + assert :sha => "MYSHA" |
| 115 | +
|
| 116 | + json :merged => true, |
| 117 | + :sha => "MERGESHA", |
| 118 | + :message => "All done!" |
| 119 | + } |
| 120 | + """ |
| 121 | + When I successfully run `hub pr merge 12 --head-sha MYSHA` |
| 122 | + Then the output should contain exactly "" |
| 123 | + |
| 124 | + Scenario: Delete branch |
| 125 | + Given the GitHub API server: |
| 126 | + """ |
| 127 | + put('/repos/friederbluemle/hub/pulls/12/merge'){ |
| 128 | + json :merged => true, |
| 129 | + :sha => "MERGESHA", |
| 130 | + :message => "All done!" |
| 131 | + } |
| 132 | +
|
| 133 | + get('/repos/friederbluemle/hub/pulls/12'){ |
| 134 | + json \ |
| 135 | + :number => 12, |
| 136 | + :state => "merged", |
| 137 | + :base => { |
| 138 | + :ref => "main", |
| 139 | + :label => "friederbluemle:main", |
| 140 | + :repo => { :owner => { :login => "friederbluemle" } } |
| 141 | + }, |
| 142 | + :head => { |
| 143 | + :ref => "patch-1", |
| 144 | + :label => "friederbluemle:patch-1", |
| 145 | + :repo => { :owner => { :login => "friederbluemle" } } |
| 146 | + } |
| 147 | + } |
| 148 | +
|
| 149 | + delete('/repos/friederbluemle/hub/git/refs/heads/patch-1'){ |
| 150 | + status 204 |
| 151 | + } |
| 152 | + """ |
| 153 | + When I successfully run `hub pr merge -d 12` |
| 154 | + Then the output should contain exactly "" |
| 155 | + |
| 156 | + Scenario: Delete already deleted branch |
| 157 | + Given the GitHub API server: |
| 158 | + """ |
| 159 | + put('/repos/friederbluemle/hub/pulls/12/merge'){ |
| 160 | + json :merged => true, |
| 161 | + :sha => "MERGESHA", |
| 162 | + :message => "All done!" |
| 163 | + } |
| 164 | +
|
| 165 | + get('/repos/friederbluemle/hub/pulls/12'){ |
| 166 | + json \ |
| 167 | + :number => 12, |
| 168 | + :state => "merged", |
| 169 | + :base => { |
| 170 | + :ref => "main", |
| 171 | + :label => "friederbluemle:main", |
| 172 | + :repo => { :owner => { :login => "friederbluemle" } } |
| 173 | + }, |
| 174 | + :head => { |
| 175 | + :ref => "patch-1", |
| 176 | + :label => "friederbluemle:patch-1", |
| 177 | + :repo => { :owner => { :login => "friederbluemle" } } |
| 178 | + } |
| 179 | + } |
| 180 | +
|
| 181 | + delete('/repos/friederbluemle/hub/git/refs/heads/patch-1'){ |
| 182 | + status 422 |
| 183 | + json :message => "Invalid branch name" |
| 184 | + } |
| 185 | + """ |
| 186 | + When I successfully run `hub pr merge -d 12` |
| 187 | + Then the output should contain exactly "" |
| 188 | + |
| 189 | + Scenario: Delete branch on cross-repo PR |
| 190 | + Given the GitHub API server: |
| 191 | + """ |
| 192 | + put('/repos/friederbluemle/hub/pulls/12/merge'){ |
| 193 | + json :merged => true, |
| 194 | + :sha => "MERGESHA", |
| 195 | + :message => "All done!" |
| 196 | + } |
| 197 | +
|
| 198 | + get('/repos/friederbluemle/hub/pulls/12'){ |
| 199 | + json \ |
| 200 | + :number => 12, |
| 201 | + :state => "merged", |
| 202 | + :base => { |
| 203 | + :ref => "main", |
| 204 | + :label => "friederbluemle:main", |
| 205 | + :repo => { :owner => { :login => "friederbluemle" } } |
| 206 | + }, |
| 207 | + :head => { |
| 208 | + :ref => "patch-1", |
| 209 | + :label => "monalisa:patch-1", |
| 210 | + :repo => { :owner => { :login => "monalisa" } } |
| 211 | + } |
| 212 | + } |
| 213 | + """ |
| 214 | + When I successfully run `hub pr merge -d 12` |
| 215 | + Then the output should contain exactly "" |
0 commit comments