summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2017-06-15 10:59:29 +0000
committerThe Bundler Bot <bot@bundler.io>2017-06-15 10:59:29 +0000
commit955ad13d8e21117418342348c62a9c7c24a95d03 (patch)
tree5df8fc8c1d756dec55267a19ec561a416b57b221
parente9f63050534f2be3f7a468834fb548a1f0d5fc13 (diff)
parent598ab4bef8fefd0a11d8b4b735a6c13b2cfb2e78 (diff)
downloadbundler-955ad13d8e21117418342348c62a9c7c24a95d03.tar.gz
Auto merge of #5705 - bundler:seg-deprecate-github-git-source, r=indirect
[DSL] Deprecate the github source for 2.0 Closes #5699. Closes #5698. @indirect is this what you wanted?
-rw-r--r--lib/bundler/dsl.rb39
-rw-r--r--spec/other/major_deprecation_spec.rb42
2 files changed, 52 insertions, 29 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
diff --git a/spec/other/major_deprecation_spec.rb b/spec/other/major_deprecation_spec.rb
index f7a632bdcf..03c2acba69 100644
--- a/spec/other/major_deprecation_spec.rb
+++ b/spec/other/major_deprecation_spec.rb
@@ -178,17 +178,27 @@ RSpec.describe "major deprecations" do
context "with github gems" do
it "warns about the https change" do
- msg = "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`."
+ msg = <<-EOS
+The :github git source is deprecated, and will be removed in Bundler 2.0. Change any "reponame" :github sources to "username/reponame". Add this code to the top of your Gemfile to ensure it continues to work:
+
+ git_source(:github) {|repo_name| "https://github.com/\#{repo_name}.git" }
+
+ EOS
expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(msg)
subject.gem("sparks", :github => "indirect/sparks")
end
it "upgrades to https on request" do
- Bundler.settings["github.https"] = true
+ Bundler.settings.temporary "github.https" => true
+ msg = <<-EOS
+The :github git source is deprecated, and will be removed in Bundler 2.0. Change any "reponame" :github sources to "username/reponame". Add this code to the top of your Gemfile to ensure it continues to work:
+
+ git_source(:github) {|repo_name| "https://github.com/\#{repo_name}.git" }
+
+ EOS
+ expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(msg)
+ expect(Bundler::SharedHelpers).to receive(:major_deprecation).with("The `github.https` setting will be removed")
subject.gem("sparks", :github => "indirect/sparks")
- expect(Bundler::SharedHelpers).to receive(:major_deprecation).never
github_uri = "https://github.com/indirect/sparks.git"
expect(subject.dependencies.first.source.uri).to eq(github_uri)
end
@@ -197,11 +207,16 @@ RSpec.describe "major deprecations" do
context "with bitbucket gems" do
it "warns about removal" do
allow(Bundler.ui).to receive(:deprecate)
- msg = "The :bitbucket git source is deprecated, and will be removed " \
- "in Bundler 2.0. Add this code to your Gemfile to ensure it " \
- "continues to work:\n git_source(:bitbucket) do |repo_name|\n " \
- " \"https://\#{user_name}@bitbucket.org/\#{user_name}/\#{repo_name}" \
- ".git\"\n end\n"
+ msg = <<-EOS
+The :bitbucket git source is deprecated, and will be removed in Bundler 2.0. Add this code to the top of your Gemfile to ensure it continues to work:
+
+ git_source(:bitbucket) do |repo_name|
+ user_name, repo_name = repo_name.split("/")
+ repo_name ||= user_name
+ "https://\#{user_name}@bitbucket.org/\#{user_name}/\#{repo_name}.git"
+ end
+
+ EOS
expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(msg)
subject.gem("not-really-a-gem", :bitbucket => "mcorp/flatlab-rails")
end
@@ -211,10 +226,9 @@ RSpec.describe "major deprecations" do
it "warns about removal" do
allow(Bundler.ui).to receive(:deprecate)
msg = "The :gist git source is deprecated, and will be removed " \
- "in Bundler 2.0. Add this code to your Gemfile to ensure it " \
- "continues to work:\n git_source(:gist) do |repo_name|\n " \
- " \"https://gist.github.com/\#{repo_name}.git\"\n" \
- " end\n"
+ "in Bundler 2.0. Add this code to the top of your Gemfile to ensure it " \
+ "continues to work:\n\n git_source(:gist) {|repo_name| " \
+ "\"https://gist.github.com/\#{repo_name}.git\" }\n\n"
expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(msg)
subject.gem("not-really-a-gem", :gist => "1234")
end