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

Refactor remote fetcher #3017

Merged
15 commits merged into from Dec 9, 2019
Merged

Refactor remote fetcher #3017

15 commits merged into from Dec 9, 2019

Conversation

deivid-rodriguez
Copy link
Member

Description:

In rubygems/bundler#7460 I'm vendoring the uri library inside bundler to add support for using the uri version inside Gemfile's just like any other gem. However, that was not the only thing needed since bundler/setup also touches some code from this class in rubygems.

So the initial approach I took was to duplicate all the code inside bundler, replacing all reference to URI with Bundler::URI (the vendored namespace). Like in rubygems/bundler@3bcc579.

However, this is ugly and hard to maintain so in this PR I'm refactoring this class so that it is enough to override only one method in the bundler subclass, like this: https://github.com/bundler/bundler/blob/aa3a25d30383a16e002dd94c209a6078746204a7/lib/bundler/gem_remote_fetcher.rb

Tasks:

  • Describe the problem / feature
  • Write tests
  • Write code to solve the problem
  • Get code review from coworkers / friends

I will abide by the code of conduct.

@bronzdoc
Copy link
Member

bronzdoc commented Dec 6, 2019

@bundlerbot r+

ghost pushed a commit that referenced this pull request Dec 6, 2019
3017: Refactor remote fetcher r=bronzdoc a=deivid-rodriguez

# Description:

In rubygems/bundler#7460 I'm vendoring the `uri` library inside `bundler` to add support for using the `uri` version inside Gemfile's just like any other gem. However, that was not the only thing needed since `bundler/setup` also touches some code from this class in rubygems.

So the initial approach I took was to duplicate all the code inside bundler, replacing all reference to `URI` with `Bundler::URI` (the vendored namespace). Like in rubygems/bundler@3bcc579.

However, this is ugly and hard to maintain so in this PR I'm refactoring this class so that it is enough to override only one method in the `bundler` subclass, like this: https://github.com/bundler/bundler/blob/aa3a25d30383a16e002dd94c209a6078746204a7/lib/bundler/gem_remote_fetcher.rb 

# Tasks:

- [x] Describe the problem / feature
- [ ] Write tests
- [x] Write code to solve the problem
- [ ] Get code review from coworkers / friends

I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).


Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
@ghost
Copy link

ghost commented Dec 6, 2019

Build failed

  • ubuntu (2.3.x, bundler)
  • ubuntu (2.3.x, rubygems)
  • ubuntu (2.4.x, bundler)
  • ubuntu (2.4.x, rubygems)
  • ubuntu (2.5.x, bundler)
  • ubuntu (2.5.x, rubygems)
  • ubuntu (2.6.x, bundler)
  • ubuntu (2.6.x, rubygems)

@deivid-rodriguez deivid-rodriguez mentioned this pull request Dec 6, 2019
4 tasks
ghost pushed a commit that referenced this pull request Dec 6, 2019
3020: Remove regular 2.3 testing r=hsbt a=deivid-rodriguez

# Description:

From the failures at #3017, it seems that `actions/setup-ruby` dropped support for testing against ruby 2.3.

So, I'm removing 2.3.x from our matrix. To ensure support until we actually drop it, I replaced it with an entry in the `rvm` file.

# Tasks:

- [x] Describe the problem / feature
- [ ] Write tests
- [x] Write code to solve the problem
- [ ] Get code review from coworkers / friends

I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).


Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
ghost pushed a commit that referenced this pull request Dec 6, 2019
3020: Remove regular 2.3 testing r=hsbt a=deivid-rodriguez

# Description:

From the failures at #3017, it seems that `actions/setup-ruby` dropped support for testing against ruby 2.3.

So, I'm removing 2.3.x from our matrix. To ensure support until we actually drop it, I replaced it with an entry in the `rvm` file.

# Tasks:

- [x] Describe the problem / feature
- [ ] Write tests
- [x] Write code to solve the problem
- [ ] Get code review from coworkers / friends

I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).


Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
@deivid-rodriguez
Copy link
Member Author

I'm actually doing some more testing on the bundler side, and it seems that this refactoring is not actually necessary... 🤷‍♂️

Expectation goes first.
`URI.parse` consistenly returns `InvalidURIError`, so we can remove one
rescue exception class and make the parsing like it looks in other
places of this file.
`URI.parse` never returns `nil`.
Because it's more straightforwards and avoid loading `URI`.
The command refers to the begin-rescue-end block, not to the
URI::Generic condition.
And pass them.

Since we already have URIs in most places, it's better to reuse them to
converting them to strings and then reparsing them to build the same URI
object.
@hsbt
Copy link
Member

hsbt commented Dec 9, 2019

@bundlerbot merge

ghost pushed a commit that referenced this pull request Dec 9, 2019
3017: Refactor remote fetcher r=hsbt a=deivid-rodriguez

# Description:

In rubygems/bundler#7460 I'm vendoring the `uri` library inside `bundler` to add support for using the `uri` version inside Gemfile's just like any other gem. However, that was not the only thing needed since `bundler/setup` also touches some code from this class in rubygems.

So the initial approach I took was to duplicate all the code inside bundler, replacing all reference to `URI` with `Bundler::URI` (the vendored namespace). Like in rubygems/bundler@3bcc579.

However, this is ugly and hard to maintain so in this PR I'm refactoring this class so that it is enough to override only one method in the `bundler` subclass, like this: https://github.com/bundler/bundler/blob/aa3a25d30383a16e002dd94c209a6078746204a7/lib/bundler/gem_remote_fetcher.rb 

# Tasks:

- [x] Describe the problem / feature
- [ ] Write tests
- [x] Write code to solve the problem
- [ ] Get code review from coworkers / friends

I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).


Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
@ghost
Copy link

ghost commented Dec 9, 2019

Build succeeded

  • macos (2.4.x)
  • macos (2.5.x)
  • macos (2.6.x)
  • ruby_master
  • ubuntu (2.4.x, bundler)
  • ubuntu (2.4.x, rubygems)
  • ubuntu (2.5.x, bundler)
  • ubuntu (2.5.x, rubygems)
  • ubuntu (2.6.x, bundler)
  • ubuntu (2.6.x, rubygems)
  • ubuntu_bundler_master (2.6.x)
  • ubuntu_lint
  • ubuntu_rvm (2.3.8)
  • ubuntu_rvm (jruby-9.2.9.0)
  • ubuntu_rvm (ruby-head)
  • windows (2.4.x)
  • windows (2.5.x)
  • windows (2.6.x)

@ghost ghost merged commit c669214 into master Dec 9, 2019
@ghost ghost deleted the refactor_remote_fetcher branch December 9, 2019 07:08
@deivid-rodriguez
Copy link
Member Author

As I mentioned in the previous comment, this PR wasn't necessary in the end, but it doesn't hurt either I think, so thanks for reviewing and merging :)

@bronzdoc
Copy link
Member

bronzdoc commented Dec 9, 2019

@hsbt please don't merge PR's tagged as wip 😬

@deivid-rodriguez
Copy link
Member Author

Right, I marked it as WIP because I wanted to tweak something else before setting it for review. Let me update what I wanted to improve on a separate PR.

@deivid-rodriguez
Copy link
Member Author

Forget about it, I think it's fine as it is.

@hsbt
Copy link
Member

hsbt commented Dec 10, 2019

ah sorry. I believe we start to use draft pull request instead of wip label or wip title. It's great to see wip status for everyone.

@hsbt hsbt added this to the 3.1.0 milestone Dec 13, 2019
hsbt pushed a commit that referenced this pull request Dec 13, 2019
3017: Refactor remote fetcher r=hsbt a=deivid-rodriguez

# Description:

In rubygems/bundler#7460 I'm vendoring the `uri` library inside `bundler` to add support for using the `uri` version inside Gemfile's just like any other gem. However, that was not the only thing needed since `bundler/setup` also touches some code from this class in rubygems.

So the initial approach I took was to duplicate all the code inside bundler, replacing all reference to `URI` with `Bundler::URI` (the vendored namespace). Like in rubygems/bundler@3bcc579.

However, this is ugly and hard to maintain so in this PR I'm refactoring this class so that it is enough to override only one method in the `bundler` subclass, like this: https://github.com/bundler/bundler/blob/aa3a25d30383a16e002dd94c209a6078746204a7/lib/bundler/gem_remote_fetcher.rb 

# Tasks:

- [x] Describe the problem / feature
- [ ] Write tests
- [x] Write code to solve the problem
- [ ] Get code review from coworkers / friends

I will abide by the [code of conduct](https://github.com/rubygems/rubygems/blob/master/CODE_OF_CONDUCT.md).


Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
This pull request was closed.
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.

None yet

3 participants