-
Notifications
You must be signed in to change notification settings - Fork 18
Enable irb flags for local geordi config and prioritize irb flags from config above default behavior #239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
6c1e956 to
bf151f0
Compare
codener
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Bruno, thanks for this PR. The code is alright, but I'd like to change one detail plus have tests restructured a bit. Could you have a look?
features/console.feature
Outdated
| """ | ||
| When I run `geordi console staging` | ||
| Then the output should contain "# Opening a Rails console on staging" | ||
| And the output should contain "Util.run! ssh, [email protected], -t, cd /var/www/example.com/current && bash --login -c 'bundle exec rails console -e staging -- --foo --baz" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please explicitly expect to not see "nomultiline" as in the scenarios above. Otherwise it might have been printed right after --baz. Same below.
features/console.feature
Outdated
| And the output should contain "Util.run! ssh, [email protected], -t, cd /var/www/example.com/current && bash --login -c 'bundle exec rails console -e staging -- --foo --baz" | ||
|
|
||
|
|
||
| Scenario: Opening a remote Rails console with an irb version >= 1.2.0, a Ruby version < 3.0 and preconfigured irb flags from local and global settings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is really important to choose scenario titles not to repeat the text below, but such that they convey their background and intention. The current scenario titles are hardly graspable.
Lets make the scenario titles clearer. I'd like them like this:
- 4: IRB < 1.2.0 has no pasting issues and thus needs no --nomultiline switch
- 13: IRB on Ruby 3+ has no pasting issues and thus needs no --nomultiline switch
- 21: IRB 1.2.0+ on Ruby <3 is horribly slow when pasting long strings – we work around this by automatically setting the --nomultiline switch
- 30: Opening a remote Rails console with a slow pasting IRB sets the --nomultiline switch
- 48: Opening a remote Rails console with a slow pasting IRB and IRB flags from the global settings does not set the --nomultiline switch
- 66: IRB flags in local Geordi settings override global and automatic IRB flags
- 85: Empty IRB flags in the local Geordi settings also override global IRB flags
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I just realized that most of these cases should be unit tests of Util#console_command. Let's only preserve these integration tests:
- 4: Opening a local Rails console
- 21: IRB 1.2.0+ on Ruby <3 is horribly slow when pasting long strings – we work around this by automatically setting the --nomultiline switch
- 30: Opening a remote Rails console with a slow pasting IRB sets the --nomultiline switch
- 85: Empty IRB flags in the local Geordi settings override global and automatic IRB flags
All others should be turned into unit tests of Util#console_command.
features/console.feature
Outdated
| And the output should contain "Util.run! ssh, [email protected], -t, cd /var/www/example.com/current && bash --login -c 'bundle exec rails console -e staging -- --foo --baz" | ||
|
|
||
|
|
||
| Scenario: Opening a remote Rails console with an irb version >= 1.2.0, a Ruby version < 3.0 and empty irb flags in local settings and preconfigured irb flags in global settings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless it's hard to implement, this should be a unit test, as it is an edge case of the scenario above.
features/console.feature
Outdated
| When I run `geordi console staging` | ||
| Then the output should contain "# Opening a Rails console on staging" | ||
| And the output should contain "Util.run! ssh, [email protected], -t, cd /var/www/example.com/current && bash --login -c 'bundle exec rails console -e staging -- --nomultiline --foo --baz" | ||
| And the output should contain "Util.run! ssh, [email protected], -t, cd /var/www/example.com/current && bash --login -c 'bundle exec rails console -e staging -- --foo --baz" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we settle that global IRB flags should kill the nomultiline switch? I'm afraid this might be impractical.
Could we add the nomultiline switch to flags taken from the global config, and only let locale config override that?
Since we're still supporting Ruby 2.7, we cannot yet get rid of all this code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I guess there was a misunderstand in that case, I thought that was what we settled on.
However, IMHO I think we should use the global irb_flags, if they have been configured. If people have set global irb flags, they have done so intentionally and should know their flags and should be able to set the --no-multiline if they need to. If they don't care enough to set irb_flags, they'll still get the --no-multiline option. For me, it would be kind of unexpected if options work differently between local and global settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed and agreed to merge the automatic --nomultiline switch with flags taken from the global config, and only let locale config override that. It's an extra piece of complexity, but the best solution we found.
lib/geordi/util.rb
Outdated
| irb_flags_from_config | ||
| elsif irb_version >= Gem::Version.new('1.2') && ruby_version < Gem::Version.new('3.0') | ||
| Interaction.note 'Using --nomultiline switch for faster pasting' | ||
| '--nomultiline' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you could pass this to Settings#irb_flags as "extra" flag, and only return it with the global flags?
| end | ||
|
|
||
|
|
||
| describe '#irb_flags', type: :aruba do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After updating the other tests, please remove example in this file that have been covered by other tests.
codener
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pushing this through!
lib/geordi/settings.rb
Outdated
| return [@local_settings['irb_flags'].to_s, :local] if @local_settings.key? 'irb_flags' | ||
| [@global_settings['irb_flags'].to_s, :global] if @global_settings.key? 'irb_flags' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be more idiomatic as:
| return [@local_settings['irb_flags'].to_s, :local] if @local_settings.key? 'irb_flags' | |
| [@global_settings['irb_flags'].to_s, :global] if @global_settings.key? 'irb_flags' | |
| if @local_settings.key? 'irb_flags' | |
| [@local_settings['irb_flags'].to_s, :local] | |
| elsif @global_settings.key? 'irb_flags' | |
| [@global_settings['irb_flags'].to_s, :global] | |
| end |
4510456 to
3ff6547
Compare
No description provided.