Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Add gemfile flag to exec command #6676

Merged
merged 5 commits into from
Sep 3, 2018

Conversation

ankitkataria
Copy link
Contributor

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

This PR resolves the issue #5924

What was your diagnosis of the problem?

  • added a gemfile flag in cli.rb
  • if options[:gemfile] is set I created a SharedHelper method custom_gemfile which used the predefined find_file function to find and set the environment variable with the argument provided

@ghost
Copy link

ghost commented Aug 24, 2018

Thanks for opening a pull request and helping make Bundler better! Someone from the Bundler 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 Travis CI to test and make sure your change works functionally and uses acceptable conventions, you can review the current progress of Travis CI 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 #bundler channel on Slack.

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

@blackgurl1981
Copy link

Hi

@colby-swandale
Copy link
Member

This needs a test to make sure the feature is behaving as expected and to make sure it will continue to work when new changes are made.

@ankitkataria
Copy link
Contributor Author

@colby-swandale I'll start working on the test. Will update the pr asap. 😉

@ankitkataria ankitkataria changed the title Add gemfile flag to exec command WIP: Add gemfile flag to exec command Aug 24, 2018

bundle "exec --gemfile CustomGemfile test"

expect(ENV["BUNDLE_GEMFILE"]).to eq("CustomGemfile")
Copy link
Member

Choose a reason for hiding this comment

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

I dont think this will test what you want it to, because the bundle helper actually runs bundler in a subprocess

@ankitkataria ankitkataria changed the title WIP: Add gemfile flag to exec command Add gemfile flag to exec command Aug 27, 2018
@ankitkataria
Copy link
Contributor Author

@segiddins Thankyou so much for your comment 😄 I understood what I was doing wrong. I've updated the test now.

Copy link
Member

@colby-swandale colby-swandale left a comment

Choose a reason for hiding this comment

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

This is pretty much ready to merge

@@ -23,6 +23,10 @@ def initialize(options, args)
def run
validate_cmd!
SharedHelpers.set_bundle_environment

# setting the gemfile if mentioned
Copy link
Member

Choose a reason for hiding this comment

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

This comment doesn't seem all that useful, the code already explains this

@colby-swandale colby-swandale added this to the 1.17.0 milestone Aug 30, 2018
@colby-swandale
Copy link
Member

Great! Thank you! 🎉

@bundlerbot r+

@bundlerbot
Copy link
Collaborator

📌 Commit 546d0a5 has been approved by colby-swandale

@bundlerbot
Copy link
Collaborator

⌛ Testing commit 546d0a5 with merge b8544ed...

bundlerbot added a commit that referenced this pull request Aug 30, 2018
Add gemfile flag to exec command

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

This PR resolves the issue #5924

### What was your diagnosis of the problem?

- added a `gemfile` flag in `cli.rb`
- if `options[:gemfile]` is set I created a SharedHelper method `custom_gemfile` which used the predefined `find_file` function to find and set the environment variable with the argument provided
@bundlerbot
Copy link
Collaborator

💔 Test failed - status-travis

@ankitkataria
Copy link
Contributor Author

@colby-swandale I don't understand why the jobs corresponding to the failing tests were canceled. What needs to be done? 🤔

@@ -6,6 +6,22 @@
system_gems(system_gems_to_install, :path => :bundle_path)
end

it "works with --gemfile flag" do
create_file "CustomGemfile", <<-G
Copy link
Member

Choose a reason for hiding this comment

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

Thinking more about this test, do you need 2 different Gemfiles?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did that to ensure that the environment variable was set correctly both the times and rackup produced the version corresponding to the mentioned gemfiles.

Copy link
Member

Choose a reason for hiding this comment

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

You're already testing bundle exec with the --gemfile option. So testing it again is redundant, can you please remove it.

@@ -230,6 +230,11 @@ def write_to_gemfile(gemfile_path, contents)
filesystem_access(gemfile_path) {|g| File.open(g, "w") {|file| file.puts contents } }
end

def custom_gemfile(gemfile)
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit confused about this method's name, it's setting an ENV var for the given Gemfile if it exists, so i'm not sure what custom_gemfile means here. This logic also seems pretty particular to bundle exec, does this need to be a method in SharedHelpers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was mentioned in the issue that the flag could be extended to other commands as well for consistency. So I made a shared helper which could be used later.
I used "custom" in the sense that it was mentioned by the user. if it is not mentioned then the default gemfiles will be used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@colby-swandale does this explanation make sense? is there a requirement to change the name of the function? 🤔

Copy link
Member

@colby-swandale colby-swandale Sep 2, 2018

Choose a reason for hiding this comment

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

You should be able to use the custom Gemfile logic in the CLI

@ankitkataria
Copy link
Contributor Author

Looking at the code in CLI There seemed to be no need of the shared helper. I removed it. Also removed the redundant test. Thankyou for the help @colby-swandale 😄

@colby-swandale
Copy link
Member

Thanks! @bundlerbot r+

@bundlerbot
Copy link
Collaborator

📌 Commit 94b7104 has been approved by colby-swandale

@bundlerbot
Copy link
Collaborator

⌛ Testing commit 94b7104 with merge 78626f6...

bundlerbot added a commit that referenced this pull request Sep 3, 2018
Add gemfile flag to exec command

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

This PR resolves the issue #5924

### What was your diagnosis of the problem?

- added a `gemfile` flag in `cli.rb`
- if `options[:gemfile]` is set I created a SharedHelper method `custom_gemfile` which used the predefined `find_file` function to find and set the environment variable with the argument provided
@colby-swandale
Copy link
Member

@bundlerbot retry

@bundlerbot
Copy link
Collaborator

⌛ Testing commit 94b7104 with merge c489248...

bundlerbot added a commit that referenced this pull request Sep 3, 2018
Add gemfile flag to exec command

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

This PR resolves the issue #5924

### What was your diagnosis of the problem?

- added a `gemfile` flag in `cli.rb`
- if `options[:gemfile]` is set I created a SharedHelper method `custom_gemfile` which used the predefined `find_file` function to find and set the environment variable with the argument provided
@bundlerbot
Copy link
Collaborator

☀️ Test successful - status-travis
Approved by: colby-swandale
Pushing c489248 to master...

@bundlerbot bundlerbot merged commit 94b7104 into rubygems:master Sep 3, 2018
colby-swandale pushed a commit that referenced this pull request Sep 21, 2018
Add gemfile flag to exec command

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

This PR resolves the issue #5924

### What was your diagnosis of the problem?

- added a `gemfile` flag in `cli.rb`
- if `options[:gemfile]` is set I created a SharedHelper method `custom_gemfile` which used the predefined `find_file` function to find and set the environment variable with the argument provided

(cherry picked from commit c489248)
colby-swandale pushed a commit that referenced this pull request Sep 22, 2018
Add gemfile flag to exec command

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

This PR resolves the issue #5924

### What was your diagnosis of the problem?

- added a `gemfile` flag in `cli.rb`
- if `options[:gemfile]` is set I created a SharedHelper method `custom_gemfile` which used the predefined `find_file` function to find and set the environment variable with the argument provided

(cherry picked from commit c489248)
colby-swandale pushed a commit that referenced this pull request Oct 5, 2018
Add gemfile flag to exec command

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

This PR resolves the issue #5924

### What was your diagnosis of the problem?

- added a `gemfile` flag in `cli.rb`
- if `options[:gemfile]` is set I created a SharedHelper method `custom_gemfile` which used the predefined `find_file` function to find and set the environment variable with the argument provided

(cherry picked from commit c489248)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants