diff options
author | Jean Boussier <jean.boussier@gmail.com> | 2021-12-02 12:59:45 +0100 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2021-12-06 20:27:29 +0900 |
commit | 715a51a0d6963f9d727191d4e1ad0690fd28c4dd (patch) | |
tree | c4ea59b85fdf346526b052839bb455ddbd4dca65 /spec | |
parent | d044ffd77fb3a486bbaca350980beee3f222bdb1 (diff) |
[rubygems/rubygems] Feature: accept pull request URLs as github source
Very often github source is used to temporarily use a modified gem
while a PR upstream is being reviewed.
So for instance https://github.com/ruby/bigdecimal/pull/211 will look like:
```ruby
gem "bigdecimal", github: "casperisfine/bigdecimal", branch: "git-gem" # https://github.com/ruby/bigdecimal/pull/200
```
It's annoying because you have to fiddle with the branch name, which is copied as `casperisfine:git-gem`, etc etc.
If I could simply use the PR URL like this:
```
gem "bigdecimal", github: "https://github.com/ruby/bigdecimal/pull/211"
```
It would make a very common task for me so much simpler.
https://github.com/rubygems/rubygems/commit/517c527751
Diffstat (limited to 'spec')
-rw-r--r-- | spec/bundler/bundler/dsl_spec.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/bundler/bundler/dsl_spec.rb b/spec/bundler/bundler/dsl_spec.rb index 4d14949c89..a44a12924c 100644 --- a/spec/bundler/bundler/dsl_spec.rb +++ b/spec/bundler/bundler/dsl_spec.rb @@ -25,6 +25,45 @@ RSpec.describe Bundler::Dsl do expect { subject.git_source(:example) }.to raise_error(Bundler::InvalidOption) end + it "converts :github PR to URI using https" do + subject.gem("sparks", :github => "https://github.com/indirect/sparks/pull/5") + github_uri = "https://github.com/indirect/sparks.git" + expect(subject.dependencies.first.source.uri).to eq(github_uri) + expect(subject.dependencies.first.source.branch).to eq("refs/pull/5/head") + end + + it "rejects :github PR URI with a branch, ref or tag" do + expect do + subject.gem("sparks", :github => "https://github.com/indirect/sparks/pull/5", :branch => "foo") + end.to raise_error( + Bundler::GemfileError, + %(The :branch option can't be used with `github: "https://github.com/indirect/sparks/pull/5"`), + ) + + expect do + subject.gem("sparks", :github => "https://github.com/indirect/sparks/pull/5", :ref => "foo") + end.to raise_error( + Bundler::GemfileError, + %(The :ref option can't be used with `github: "https://github.com/indirect/sparks/pull/5"`), + ) + + expect do + subject.gem("sparks", :github => "https://github.com/indirect/sparks/pull/5", :tag => "foo") + end.to raise_error( + Bundler::GemfileError, + %(The :tag option can't be used with `github: "https://github.com/indirect/sparks/pull/5"`), + ) + end + + it "rejects :github with :git" do + expect do + subject.gem("sparks", :github => "indirect/sparks", :git => "https://github.com/indirect/sparks.git") + end.to raise_error( + Bundler::GemfileError, + %(The :git option can't be used with `github: "indirect/sparks"`), + ) + end + context "default hosts", :bundler => "< 3" do it "converts :github to URI using https" do subject.gem("sparks", :github => "indirect/sparks") |