diff options
| author | Samuel Giddins <segiddins@segiddins.me> | 2017-06-04 16:05:17 -0500 |
|---|---|---|
| committer | Samuel Giddins <segiddins@segiddins.me> | 2017-06-14 10:28:16 -0500 |
| commit | 598ab4bef8fefd0a11d8b4b735a6c13b2cfb2e78 (patch) | |
| tree | 0fbb14b9e2ce46facc0025ae37f7bf368ee501ea /lib/bundler/dsl.rb | |
| parent | ddcca6254cc4e63cbb25b78f8ec93462fa56249c (diff) | |
| download | bundler-598ab4bef8fefd0a11d8b4b735a6c13b2cfb2e78.tar.gz | |
[DSL] Deprecate the github source for 2.0seg-deprecate-github-git-source
Diffstat (limited to 'lib/bundler/dsl.rb')
| -rw-r--r-- | lib/bundler/dsl.rb | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index 2d219edcc7..665724f54d 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -252,6 +252,9 @@ module Bundler def add_git_sources git_source(:github) do |repo_name| + warn_deprecated_git_source(:github, <<-'RUBY'.strip, 'Change any "reponame" :github sources to "username/reponame".') +"https://github.com/#{repo_name}.git" + RUBY # It would be better to use https instead of the git protocol, but this # can break deployment of existing locked bundles when switching between # different versions of Bundler. The change will be made in 2.0, which @@ -268,23 +271,29 @@ module Bundler repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") # TODO: 2.0 upgrade this setting to the default if Bundler.settings["github.https"] + Bundler::SharedHelpers.major_deprecation "The `github.https` setting will be removed" "https://github.com/#{repo_name}.git" else - warn_github_source_change(repo_name) "git://github.com/#{repo_name}.git" end end # TODO: 2.0 remove this deprecated git source git_source(:gist) do |repo_name| - warn_deprecated_git_source(:gist, 'https://gist.github.com/#{repo_name}.git') + warn_deprecated_git_source(:gist, '"https://gist.github.com/#{repo_name}.git"') + "https://gist.github.com/#{repo_name}.git" end # TODO: 2.0 remove this deprecated git source git_source(:bitbucket) do |repo_name| - user_name, repo_name = repo_name.split "/" - warn_deprecated_git_source(:bitbucket, 'https://#{user_name}@bitbucket.org/#{user_name}/#{repo_name}.git') + warn_deprecated_git_source(:bitbucket, <<-'RUBY'.strip) +user_name, repo_name = repo_name.split("/") +repo_name ||= user_name +"https://#{user_name}@bitbucket.org/#{user_name}/#{repo_name}.git" + RUBY + + user_name, repo_name = repo_name.split("/") repo_name ||= user_name "https://#{user_name}@bitbucket.org/#{user_name}/#{repo_name}.git" end @@ -439,20 +448,20 @@ module Bundler end end - def warn_github_source_change(repo_name) + def warn_deprecated_git_source(name, replacement, additional_message = nil) # TODO: 2.0 remove deprecation - Bundler::SharedHelpers.major_deprecation "The :github option uses the git: protocol, which is not secure. " \ - "Bundler 2.0 will use the https: protocol, which is secure. Enable this change now by " \ - "running `bundle config github.https true`." - end + additional_message &&= " #{additional_message}" + replacement = if replacement.count("\n").zero? + "{|repo_name| #{replacement} }" + else + "do |repo_name|\n#{replacement.to_s.gsub(/^/, " ")}\n end" + end - def warn_deprecated_git_source(name, repo_string) - # TODO: 2.0 remove deprecation Bundler::SharedHelpers.major_deprecation <<-EOS -The :#{name} git source is deprecated, and will be removed in Bundler 2.0. Add this code to your Gemfile to ensure it continues to work: - git_source(:#{name}) do |repo_name| - "#{repo_string}" - end +The :#{name} git source is deprecated, and will be removed in Bundler 2.0.#{additional_message} Add this code to the top of your Gemfile to ensure it continues to work: + + git_source(:#{name}) #{replacement} + EOS end |
