From b5c62a05d4f581ba7292b7d155daedada007cde9 Mon Sep 17 00:00:00 2001 From: Colby Swandale Date: Mon, 19 Nov 2018 22:59:08 +1100 Subject: [PATCH 1/3] add feature flag (enabled in Bundler 2 by default) that will set the :github source to use https by default --- lib/bundler/dsl.rb | 5 ++--- lib/bundler/feature_flag.rb | 1 + lib/bundler/settings.rb | 1 + man/bundle-config.ronn | 3 +++ spec/bundler/dsl_spec.rb | 14 ++++++++++++-- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index 80d208e463d..e1b38c46624 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -304,9 +304,8 @@ def add_git_sources # "https://github.com/#{repo_name}.git" # end 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 2, "The `github.https` setting will be removed" + if Bundler.settings["github.https"] || Bundler.feature_flag.github_https_source? + Bundler::SharedHelpers.major_deprecation 2, "The `github.https` setting will ba removed" if Bundler.settings["github.https"] "https://github.com/#{repo_name}.git" else "git://github.com/#{repo_name}.git" diff --git a/lib/bundler/feature_flag.rb b/lib/bundler/feature_flag.rb index 83e7ff0389a..c38a81ac799 100644 --- a/lib/bundler/feature_flag.rb +++ b/lib/bundler/feature_flag.rb @@ -39,6 +39,7 @@ def self.settings_method(name, key, &default) settings_flag(:disable_multisource) { bundler_2_mode? } settings_flag(:error_on_stderr) { bundler_2_mode? } settings_flag(:forget_cli_options) { bundler_2_mode? } + settings_flag(:github_https_source) { bundler_2_mode? } settings_flag(:global_path_appends_ruby_scope) { bundler_2_mode? } settings_flag(:global_gem_cache) { bundler_2_mode? } settings_flag(:init_gems_rb) { bundler_2_mode? } diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index fe68d510ffa..3121eb20e70 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -35,6 +35,7 @@ class Settings frozen gem.coc gem.mit + github_https_source global_path_appends_ruby_scope global_gem_cache ignore_messages diff --git a/man/bundle-config.ronn b/man/bundle-config.ronn index 379b778348a..b88bbb73b79 100644 --- a/man/bundle-config.ronn +++ b/man/bundle-config.ronn @@ -195,6 +195,9 @@ learn more about their operation in [bundle install(1)](bundle-install.1.html). relative paths in the `Gemfile`, among other things. By default, bundler will search up from the current working directory until it finds a `Gemfile`. +* `github_https_source` (`GITHUB_HTTPS_SOURCE`) + Set Bundler to use https by default when using the `github:` source in the + Gemfile * `global_gem_cache` (`BUNDLE_GLOBAL_GEM_CACHE`): Whether Bundler should cache all gems globally, rather than locally to the installing Ruby installation. diff --git a/spec/bundler/dsl_spec.rb b/spec/bundler/dsl_spec.rb index bffe4f16083..2660e5eb462 100644 --- a/spec/bundler/dsl_spec.rb +++ b/spec/bundler/dsl_spec.rb @@ -25,8 +25,18 @@ expect { subject.git_source(:example) }.to raise_error(Bundler::InvalidOption) end - context "default hosts (git, gist)", :bundler => "< 2" do + context "default hosts (git, gist)" do + # Note: There is a feature flag that will disabled these soruces by + # default + before { bundle "config skip_default_git_sources false" } + it "converts :github to :git" do + subject.gem("sparks", :github => "indirect/sparks") + github_uri = "https://github.com/indirect/sparks.git" + expect(subject.dependencies.first.source.uri).to eq(github_uri) + end + + it "converts :github to :git with git scheme", :bundler => "< 2" do subject.gem("sparks", :github => "indirect/sparks") github_uri = "git://github.com/indirect/sparks.git" expect(subject.dependencies.first.source.uri).to eq(github_uri) @@ -46,7 +56,7 @@ it "converts 'rails' to 'rails/rails'" do subject.gem("rails", :github => "rails") - github_uri = "git://github.com/rails/rails.git" + github_uri = "https://github.com/rails/rails.git" expect(subject.dependencies.first.source.uri).to eq(github_uri) end From 9873bfc64c10ef420c0e89e7f6cb5ccb343cf023 Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Tue, 20 Nov 2018 06:13:29 +1100 Subject: [PATCH 2/3] Update lib/bundler/dsl.rb Co-Authored-By: colby-swandale --- lib/bundler/dsl.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index e1b38c46624..2b22ba6e3d9 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -305,7 +305,7 @@ def add_git_sources # end repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") if Bundler.settings["github.https"] || Bundler.feature_flag.github_https_source? - Bundler::SharedHelpers.major_deprecation 2, "The `github.https` setting will ba removed" if Bundler.settings["github.https"] + Bundler::SharedHelpers.major_deprecation 2, "The `github.https` setting will be removed" if Bundler.settings["github.https"] "https://github.com/#{repo_name}.git" else "git://github.com/#{repo_name}.git" From d88d22aa702daae3a4bde3770b81729e2a8aff5d Mon Sep 17 00:00:00 2001 From: Olle Jonsson Date: Tue, 20 Nov 2018 06:13:46 +1100 Subject: [PATCH 3/3] Update spec/bundler/dsl_spec.rb Co-Authored-By: colby-swandale --- spec/bundler/dsl_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/bundler/dsl_spec.rb b/spec/bundler/dsl_spec.rb index 2660e5eb462..bd984f96a68 100644 --- a/spec/bundler/dsl_spec.rb +++ b/spec/bundler/dsl_spec.rb @@ -26,7 +26,7 @@ end context "default hosts (git, gist)" do - # Note: There is a feature flag that will disabled these soruces by + # Note: There is a feature flag that will disable these sources by # default before { bundle "config skip_default_git_sources false" }