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

Prevent remove command from deleting gemfile lines that are comments #4045

Conversation

jlgoedert
Copy link
Contributor

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

Running bundle remove foo, removes the respective gem, "foo", from the Gemfile, but also removes any comments containing gem "foo", where "foo" is the name of the removed gem (fixes #3276).

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

In the code that removes text from gemfiles, there is a regular expression that identifies lines where the gems targeted for removal are mentioned. To complement this, I use an additional regular expression to make sure the mention of the gem is not a line comment.

I included two tests. One test verifies such a line comment is not deleted. The other test makes sure a typical inline comment is still removed in a normal bundle remove scenario.

Please let me know if you think there are important cases that I missed. It is my understanding that the

=begin
=end 

comment syntax is very rarely used.

Any and all feedback is greatly appreciated!

Make sure he following tasks are checked

@welcome
Copy link

welcome bot commented Nov 1, 2020

Thanks for opening a pull request and helping make RubyGems and Bundler better! Someone from the RubyGems team will take a look at your pull request shortly and leave any feedback. Please make sure that your pull request has tests for any changes or added functionality.

We use GitHub Actions to test and make sure your change works functionally and uses acceptable conventions, you can review the current progress of GitHub Actions in the PR status window below.

If you have any questions or concerns that you wish to ask, feel free to leave a comment in this PR or join our #rubygems or #bundler channel on Slack.

For more information about contributing to the RubyGems project feel free to review our CONTRIBUTING guide

@deivid-rodriguez deivid-rodriguez merged commit 2d0fa4a into rubygems:master Nov 10, 2020
deivid-rodriguez added a commit that referenced this pull request Dec 7, 2020
…_handling

Prevent remove command from deleting gemfile lines that are comments

(cherry picked from commit 2d0fa4a)
deivid-rodriguez added a commit that referenced this pull request Dec 7, 2020
…_handling

Prevent remove command from deleting gemfile lines that are comments

(cherry picked from commit 2d0fa4a)
deivid-rodriguez added a commit that referenced this pull request Dec 7, 2020
…_handling

Prevent remove command from deleting gemfile lines that are comments

(cherry picked from commit 2d0fa4a)
deivid-rodriguez added a commit that referenced this pull request Dec 7, 2020
…_handling

Prevent remove command from deleting gemfile lines that are comments

(cherry picked from commit 2d0fa4a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'bundle remove GEM' removes comments containing 'gem "GEM"'
2 participants