Skip to content

Conversation

@colby-swandale
Copy link
Member

What was the end-user or developer problem that led to this PR?

The bundle gem command has been using the Contributor Covenant since 2014, but it was recently updated to the Ruby CoC when the RubyGems project was moved under the Ruby Organization.

I want to improve the project by updating the bundle gem command to offer a choice between the two going forward. This will also allow the Ruby community to nominate any future Code of Conducts more easily if needed.

What is your fix for the problem, implemented in this PR?

This Pull Request updates the bundle gem --coc option to allow users to select between the Ruby CoC or the Contributor Covenant. It takes into account any previous configuration (before: Boolean, after: String) for this option and handles the migration to the new functionality appropriately.

Make sure the following tasks are checked

Copilot AI review requested due to automatic review settings January 19, 2026 06:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR expands the bundle gem command to allow users to choose between different Code of Conducts (Contributor Covenant or Ruby Community Conduct Guideline) instead of a boolean on/off option. The change migrates the configuration from a boolean to a string value while maintaining backward compatibility with existing boolean configurations.

Changes:

  • Updated --coc option to accept string values: contributor-covenant, ruby, or none
  • Added two new Code of Conduct templates for the different options
  • Implemented backward compatibility logic to migrate legacy boolean values (true/false) to the new string-based system
  • Updated tests to cover all new functionality and edge cases

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
bundler/spec/commands/newgem_spec.rb Comprehensive test coverage for new CoC options, backward compatibility, and configuration behavior
bundler/lib/bundler/templates/newgem/RUBY_SRC_CODE_OF_CONDUCT.md.tt New template for Ruby Community Conduct Guideline
bundler/lib/bundler/templates/newgem/CONTRIBUTOR_COVENANT_CODE_OF_CONDUCT.md.tt New template for Contributor Covenant v3.0
bundler/lib/bundler/settings.rb Moved gem.coc from BOOL_KEYS to STRING_KEYS to support string values
bundler/lib/bundler/man/bundle-gem.1.ronn Updated documentation for the new --coc options
bundler/lib/bundler/cli/gem.rb Implemented ask_and_set_coc method with backward compatibility logic
bundler/lib/bundler/cli.rb Updated method_option for --coc to accept string enum with lazy_default

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +395 to +401
coc_template = options[:coc] || Bundler.settings["gem.coc"]

# Handle backwards compatibility: if the old boolean `false` value is set,
# silently migrate to the new `none` value and honor the setting
if coc_template.to_s == "false"
Bundler.settings.set_global("gem.coc", "none")
return "none"
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

When a user explicitly provides the --coc flag without a value while gem.coc is set to the legacy boolean value false, the code will silently migrate the setting to "none" and return early without prompting the user. This contradicts the test expectation at lines 1270-1284 which expects the user to be prompted. The issue is that line 395 falls back to Bundler.settings["gem.coc"] even when options[:coc] is explicitly set to an empty string. The backwards compatibility check should only apply when the user hasn't explicitly provided the --coc flag.

Copilot uses AI. Check for mistakes.
colby-swandale and others added 3 commits January 19, 2026 18:00
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

2 participants