Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
add feature flag to use https for :git in the dsl
Browse files Browse the repository at this point in the history
  • Loading branch information
colby-swandale committed Nov 22, 2018
1 parent f160d15 commit 15173fa
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/bundler/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions lib/bundler/feature_flag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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? }
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/bundler/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Settings
frozen
gem.coc
gem.mit
github_https
global_path_appends_ruby_scope
global_gem_cache
ignore_messages
Expand Down
16 changes: 16 additions & 0 deletions spec/bundler/dsl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions spec/quality_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 15173fa

Please sign in to comment.