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

Avoid fetching an rebuilding git gems when it's not necessary #6711

Merged
2 commits merged into from
Oct 6, 2018

Conversation

casperisfine
Copy link

Kind of a followup to #4272

The issue

As demonstrated by the updated test case, whenever a gem is changed (even a non-git one), bundler re-fetch all git gems, and recompile their extensions (if any).

You can repro that issue by running the modified git_spec.rb against master.

The proposed fix

In that patch I simply make Source::Git skip the fetch step if the cached_revision matches the install path.

Since install_path uses only the first 10 characters of the full revision, there is a very very small chance of a collision happening, but It's so small that I think it can be ignored.

However my understanding of the codebase is too limited to be 100% sure the git gem would be properly updated if it's definition (branch / ref / etc) is updated. I tried to write a test case for this but couldn't figure out how to create a repo with multiple revisions. I'll keep digging, but I figured I might as well ask for feedback at this stage.

@segiddins any thoughts on this ? (since you fixed #4272), any pointers on how to better test this?

cc @rafaelfranca @jules2689

@ghost
Copy link

ghost commented Sep 27, 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

@segiddins
Copy link
Member

I have no idea why travis choked, by I hope you dont mind me adding some tests ;)

@casperisfine
Copy link
Author

I hope you dont mind me adding some tests ;)

Absolutely not.

@segiddins
Copy link
Member

@bundlerbot r+

ghost pushed a commit that referenced this pull request Oct 6, 2018
6711: Avoid fetching an rebuilding git gems when it's not necessary r=segiddins a=casperisfine

Kind of a followup to #4272

### The issue

As demonstrated by the updated test case, whenever a gem is changed (even a non-git one), bundler re-fetch all git gems, and recompile their extensions (if any).

You can repro that issue by running the modified `git_spec.rb` against master.

### The proposed fix

In that patch I simply make `Source::Git` skip the `fetch` step if the `cached_revision` matches the install path.

Since `install_path` uses only the first 10 characters of the full revision, there is a very very small chance of a collision happening, but It's so small that I think it can be ignored.

However my understanding of the codebase is too limited to be 100% sure the git gem would be properly updated if it's definition (`branch` / `ref` / `etc`) is updated. I tried to write a test case for this but couldn't figure out how to create a repo with multiple revisions. I'll keep digging, but I figured I might as well ask for feedback at this stage.


@segiddins any thoughts on this ? (since you fixed #4272), any pointers on how to better test this?

cc @rafaelfranca @jules2689 

Co-authored-by: Jean Boussier <[email protected]>
Co-authored-by: Samuel Giddins <[email protected]>
@ghost
Copy link

ghost commented Oct 6, 2018

Build succeeded

@ghost ghost merged commit a04d97d into rubygems:master Oct 6, 2018
@casperisfine
Copy link
Author

🎉 thanks a lot for improving the coverage !

@colby-swandale colby-swandale added this to the 1.16.7 milestone Oct 12, 2018
@colby-swandale colby-swandale modified the milestones: 1.16.7, 2.0.2 Feb 25, 2019
@colby-swandale colby-swandale modified the milestones: 2.0.2, 2.1.0 Mar 23, 2019
@deivid-rodriguez deivid-rodriguez removed this from the 2.1.0 milestone Dec 13, 2019
This pull request was closed.
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