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

[#5610] Infer TargetRubyVersion from bundler lock files #5632

Merged
merged 1 commit into from
Mar 16, 2018
Merged

[#5610] Infer TargetRubyVersion from bundler lock files #5632

merged 1 commit into from
Mar 16, 2018

Conversation

roberts1000
Copy link
Contributor

Closes #5610.

Change the config init process slightly, for setting TargetRubyVersion, to consider the gems.locked or Gemfile.lock when trying to determine the best value. If the user adds ruby ... to the Gemfile, bundler will lock Ruby to a specific version and we can use that information to dynamically pick the best value for TargetRubyVersion. The .ruby-version file is still considered first before looking at lock file.

If TargetRubyVersion is set in the config file, it still takes precedence and is always used. If Ruby is not in gems.locked or Gemfile.lock, and the user hasn't specified a version in the config, the default version is still used as the fallback.


Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.
  • Run rake default or rake parallel. It executes all tests and RuboCop for itself, and generates the documentation.

# Else if .ruby-version exists and it contains an MRI version it is used.
# Otherwise we fallback to the oldest officially supported Ruby version (2.1).
# If a value is specified for TargetRubyVersion then it is used. Acceptable
# values are specificed as a float (i.e. 2.5); the patch version of Ruby
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace patch with teeny. Because the Ruby versioning format is major.minor.teeny.
https://www.ruby-lang.org/en/news/2013/12/21/ruby-version-policy-changes-with-2-1-0/

ruby-extensions (~> 1.9.0)

RUBY VERSION
ruby 2.0.0p0 (rbx 3.42)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example's description is "uses the default Ruby when jruby", but the lockfile has rbx 3.42. Should it be "jruby"?

@pocke
Copy link
Collaborator

pocke commented Mar 15, 2018

Sorry for the late review🙇

It looks good to me! 🎉 However, I have few comments. Can you confirm the comments, and rebase on the current master?

@roberts1000
Copy link
Contributor Author

No problem! Thanks for taking a look. Good catches in the comments; I made the adjustments and rebased.

@bbatsov bbatsov merged commit e7c14e1 into rubocop:master Mar 16, 2018
koic added a commit to koic/rubocop that referenced this pull request Mar 16, 2018
Follow up of rubocop@7949f49.

This PR fixes the following build error in Travis CI.
https://travis-ci.org/bbatsov/rubocop/jobs/354133118

It also removes unnecessary blank line inserted by rubocop#5632. It's just a nitpick.
@koic koic mentioned this pull request Mar 16, 2018
8 tasks
bbatsov pushed a commit that referenced this pull request Mar 17, 2018
Follow up of 7949f49.

This PR fixes the following build error in Travis CI.
https://travis-ci.org/bbatsov/rubocop/jobs/354133118

It also removes unnecessary blank line inserted by #5632. It's just a nitpick.
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