@@ -18,6 +18,8 @@ def self.evaluate(gemfile, lockfile, unlock)
1818 VALID_KEYS = %w[ group groups git path glob name branch ref tag require submodules
1919 platform platforms type source install_if gemfile ] . freeze
2020
21+ GITHUB_PULL_REQUEST_URL = %r{\A https://github\. com/([A-Za-z0-9_\- \. ]+/[A-Za-z0-9_\- \. ]+)/pull/(\d +)\z } . freeze
22+
2123 attr_reader :gemspecs
2224 attr_accessor :dependencies
2325
@@ -278,8 +280,17 @@ def add_git_sources
278280 warn_deprecated_git_source ( :github , <<-'RUBY' . strip , 'Change any "reponame" :github sources to "username/reponame".' )
279281"https://github.com/#{repo_name}.git"
280282 RUBY
281- repo_name = "#{ repo_name } /#{ repo_name } " unless repo_name . include? ( "/" )
282- "https://github.com/#{ repo_name } .git"
283+ if repo_name =~ GITHUB_PULL_REQUEST_URL
284+ {
285+ "git" => "https://github.com/#{ $1} .git" ,
286+ "branch" => "refs/pull/#{ $2} /head" ,
287+ "ref" => nil ,
288+ "tag" => nil ,
289+ }
290+ else
291+ repo_name = "#{ repo_name } /#{ repo_name } " unless repo_name . include? ( "/" )
292+ "https://github.com/#{ repo_name } .git"
293+ end
283294 end
284295
285296 git_source ( :gist ) do |repo_name |
@@ -365,7 +376,11 @@ def normalize_options(name, version, opts)
365376
366377 git_name = ( git_names & opts . keys ) . last
367378 if @git_sources [ git_name ]
368- opts [ "git" ] = @git_sources [ git_name ] . call ( opts [ git_name ] )
379+ git_opts = @git_sources [ git_name ] . call ( opts [ git_name ] )
380+ git_opts = { "git" => git_opts } if git_opts . is_a? ( String )
381+ opts . merge! ( git_opts ) do |key , _gemfile_value , _git_source_value |
382+ raise GemfileError , %(The :#{ key } option can't be used with `#{ git_name } : #{ opts [ git_name ] . inspect } `)
383+ end
369384 end
370385
371386 %w[ git path ] . each do |type |
0 commit comments