diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index 80d208e463d..a357e655502 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?("/") # TODO: 2.0 upgrade this setting to the default - if Bundler.settings["github.https"] + if Bundler.feature_flag.github_https Bundler::SharedHelpers.major_deprecation 2, "The `github.https` setting will be removed" "https://github.com/#{repo_name}.git" else diff --git a/lib/bundler/feature_flag.rb b/lib/bundler/feature_flag.rb index 83e7ff0389a..2d4b73e8312 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) { 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? } @@ -64,6 +65,12 @@ def initialize(bundler_version) @bundler_version = Gem::Version.create(bundler_version) end + def github_https(&block) + value = Bundler.settings["github.https"] + value = instance_eval(&default) if value.nil? && !default.nil? + value + end + def major_version @bundler_version.segments.first end diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index fe68d510ffa..948e7b7f4d2 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -35,6 +35,7 @@ class Settings frozen gem.coc gem.mit + github_https global_path_appends_ruby_scope global_gem_cache ignore_messages diff --git a/spec/bundler/dsl_spec.rb b/spec/bundler/dsl_spec.rb index bffe4f16083..062241cc359 100644 --- a/spec/bundler/dsl_spec.rb +++ b/spec/bundler/dsl_spec.rb @@ -25,7 +25,23 @@ expect { subject.git_source(:example) }.to raise_error(Bundler::InvalidOption) end + context "github_https feature flag" do + it "is true when github.https is true" do + bundle "config github.https true" + expect(Bundler.feature_flag.github_https).to eq "true" + end + end + context "default hosts (git, gist)", :bundler => "< 2" do + context "when github.https config is true" do + before { bundle "config github.https true" } + it "converts :github to :git using https" 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 + end + it "converts :github to :git" do subject.gem("sparks", :github => "indirect/sparks") github_uri = "git://github.com/indirect/sparks.git" diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb index e85d0bfa970..451c789ee2e 100644 --- a/spec/quality_spec.rb +++ b/spec/quality_spec.rb @@ -178,6 +178,7 @@ def check_for_specific_pronouns(filename) console_command deployment_means_frozen forget_cli_options + github_https gem.coc gem.mit inline