Skip to content
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

Version 1.9.0 has a "warning: string literal in condition" warning message #526

Closed
emmahsax opened this issue Jul 7, 2021 · 3 comments
Closed

Comments

@emmahsax
Copy link

emmahsax commented Jul 7, 2021

Subject of the issue

On the latest new version of Ruby git gem, I see this message:

/Users/emmasax/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/git-1.9.0/lib/git/lib.rb:663: warning: string literal in condition

This error is pointing to this line:

arr_opts << '--gpg-sign' if opts[:gpg_sign] == true || "--gpg-sign=#{opts[:gpg_sign]}" if opts[:gpg_sign]

Looking at the error (StackOverflow describes what the warning message means here), it seems the easiest way to fix it is to change that line to:

arr_opts << '--gpg-sign' if opts[:gpg_sign] && (opts[:gpg_sign] == true || opts[:gpg_sign] == "--gpg-sign=#{opts[:gpg_sign]}")

Your environment

  • Ruby git gem 1.9.0
  • Ruby version 3.0.1 installed with rbenv

Steps to reproduce

Using the newest version of the git Ruby gem with Ruby 3.0.1:

$ irb
irb(main):002:0> require 'git'
/Users/emmasax/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/git-1.9.0/lib/git/lib.rb:663: warning: string literal in condition
=> true

Expected behaviour

$ irb
irb(main):002:0> require 'git'
=> true

Actual behaviour

See the Steps to reproduce section.

@jcouball
Copy link
Member

jcouball commented Jul 7, 2021

Thank you for the great error report. I noticed the same warning and added a fix for it in PR #525. I'll cut a new release soon.

@jcouball
Copy link
Member

jcouball commented Jul 7, 2021

This has been fixed this in git-1.9.1:

$ gem install git -v 1.9.1
Fetching git-1.9.1.gem
Successfully installed git-1.9.1
Parsing documentation for git-1.9.1
Installing ri documentation for git-1.9.1
Done installing documentation for git after 0 seconds
1 gem installed
 $ irb
3.0.1 :001 > require 'git'
 => true
3.0.1 :002 >

@jcouball jcouball closed this as completed Jul 7, 2021
@emmahsax
Copy link
Author

emmahsax commented Jul 7, 2021

Thank you @jcouball!

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

No branches or pull requests

2 participants