This repository was archived by the owner on Apr 14, 2021. It is now read-only.
Commit 6705960
Merge #7199
7199: Allow `rake release` to ask for input (3rd take) r=colby-swandale a=deivid-rodriguez
This PR supersedes #7108 and #7005.
It fixes #6854.
### What was the end-user problem that led to this PR?
The problem was that if users has 2FA authentication on their rubygems account, `rake release` doesn't really work at the moment, since it hangs asking for the OTP code, but without letting the user know.
### What was your diagnosis of the problem?
My diagnosis was that we need to allow the `rake release` helper that shells out to `gem push` to read `gem push` output and show it to the user, so that she can introduce the requested information.
### What is your fix for the problem, implemented in this PR?
My fix is inspired by @segiddins's comment in #6854 (comment). `Kernel#system` works like we would expect in this situation.
### Why did you choose this fix out of the possible options?
I chose this fix because #7108 had a few problems:
* It would update the `sh` helper, which is used in many different places. This was unnecessary since most of the times we shell out to the `gem` CLI we don't need to ask for input, and it also produced a very verbose output in those cases, since everything the `gem` CLI prints to the screen would be printed by the bundler helpers too. This PR does not change the current output, other than for `rake release`.
* It would print _duplicate_ output. This is a `rake release` test using #7108:
```
$ RUBYOPT="-I../bundler/lib" ../bundler/exe/bundle exec rake release
Successfully built RubyGem
Name: rake_release_tester
Version: 0.1.0
File: rake_release_tester-0.1.0.gem
rake_release_tester 0.1.0 built to pkg/rake_release_tester-0.1.0.gem.
v0.1.0
Tag v0.1.0 has already been created.
Pushing gem to https://rubygems.org...
You have enabled multi-factor authentication. Please enter OTP code.
Code: asd
Your OTP code is incorrect. Please check it and retry.
rake aborted!
Pushing gem to https://rubygems.org...
You have enabled multi-factor authentication. Please enter OTP code.
Code: Your OTP code is incorrect. Please check it and retry.
/home/deivid/Code/bundler/lib/bundler/gem_helper.rb:187:in `sh'
/home/deivid/Code/bundler/lib/bundler/gem_helper.rb:109:in `rubygem_push'
/home/deivid/Code/bundler/lib/bundler/gem_helper.rb:70:in `block in install'
/home/deivid/Code/bundler/lib/bundler/cli/exec.rb:69:in `load'
/home/deivid/Code/bundler/lib/bundler/cli/exec.rb:69:in `kernel_load'
/home/deivid/Code/bundler/lib/bundler/cli/exec.rb:28:in `run'
/home/deivid/Code/bundler/lib/bundler/cli.rb:468:in `exec'
/home/deivid/Code/bundler/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/home/deivid/Code/bundler/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/home/deivid/Code/bundler/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
/home/deivid/Code/bundler/lib/bundler/cli.rb:26:in `dispatch'
/home/deivid/Code/bundler/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
/home/deivid/Code/bundler/lib/bundler/cli.rb:17:in `start'
../bundler/exe/bundle:30:in `block in <main>'
/home/deivid/Code/bundler/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
../bundler/exe/bundle:22:in `<main>'
Tasks: TOP => release => release:rubygem_push
(See full trace by running task with --trace)
```
This is the same test using this PR:
```
$ RUBYOPT="-I../bundler/lib" ../bundler/exe/bundle exec rake release
rake_release_tester 0.1.0 built to pkg/rake_release_tester-0.1.0.gem.
Tag v0.1.0 has already been created.
Pushing gem to https://rubygems.org...
You have enabled multi-factor authentication. Please enter OTP code.
Code: asdfasdf
Your OTP code is incorrect. Please check it and retry.
```
* Previous approach was hard to test. The test included here might not be great but it's something...
Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
(cherry picked from commit cd05f13)1 parent 293d743 commit 6705960
File tree
4 files changed
+45
-22
lines changed- lib/bundler
- spec
- bundler
- commands
- support
4 files changed
+45
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
| 109 | + | |
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
183 | 190 | | |
184 | 191 | | |
185 | 192 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
218 | 219 | | |
219 | 220 | | |
220 | 221 | | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
226 | 227 | | |
227 | | - | |
| 228 | + | |
| 229 | + | |
228 | 230 | | |
229 | | - | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
230 | 242 | | |
231 | 243 | | |
232 | 244 | | |
| |||
249 | 261 | | |
250 | 262 | | |
251 | 263 | | |
252 | | - | |
| 264 | + | |
253 | 265 | | |
254 | 266 | | |
255 | 267 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
| 185 | + | |
198 | 186 | | |
199 | 187 | | |
200 | 188 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
543 | 543 | | |
544 | 544 | | |
545 | 545 | | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
546 | 562 | | |
547 | 563 | | |
548 | 564 | | |
| |||
0 commit comments