Skip to content

Conversation

@brunosedler
Copy link
Contributor

No description provided.

@brunosedler brunosedler requested a review from codener August 7, 2025 12:00
@brunosedler brunosedler force-pushed the bs/use-irb-flags-from-local-geordi-config branch from 6c1e956 to bf151f0 Compare August 7, 2025 12:26
Copy link
Member

@codener codener left a 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?

"""
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"
Copy link
Member

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.

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
Copy link
Member

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

Copy link
Member

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.

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
Copy link
Member

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.

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"
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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.

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'
Copy link
Member

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
Copy link
Member

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.

@brunosedler brunosedler requested a review from codener August 29, 2025 07:28
Copy link
Member

@codener codener left a 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!

Comment on lines 29 to 30
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'
Copy link
Member

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:

Suggested change
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

@brunosedler brunosedler force-pushed the bs/use-irb-flags-from-local-geordi-config branch from 4510456 to 3ff6547 Compare August 29, 2025 12:24
@brunosedler brunosedler merged commit 3ff6547 into master Aug 29, 2025
4 checks passed
@brunosedler brunosedler deleted the bs/use-irb-flags-from-local-geordi-config branch August 29, 2025 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants