From 2d6498b84198a20e73c65734d813558f5f921ce2 Mon Sep 17 00:00:00 2001 From: Samuel Giddins Date: Fri, 28 Apr 2017 14:48:37 +0200 Subject: [RuboCop] Auto-gen config --- .rubocop_todo.yml | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 7d16768980..e9ec7c682b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2017-04-08 17:26:10 -0500 using RuboCop version 0.48.0. +# on 2017-04-28 14:46:27 +0200 using RuboCop version 0.48.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -72,12 +72,12 @@ Lint/UselessAssignment: - 'lib/bundler/index.rb' - 'lib/bundler/installer.rb' -# Offense count: 451 +# Offense count: 456 # Configuration parameters: CountComments, ExcludedMethods. Metrics/BlockLength: - Max: 988 + Max: 1048 -# Offense count: 2035 +# Offense count: 2083 # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https Metrics/LineLength: @@ -87,7 +87,6 @@ Metrics/LineLength: # Cop supports --auto-correct. Performance/RedundantBlockCall: Exclude: - - 'lib/bundler/dsl.rb' - 'lib/bundler/gem_helper.rb' - 'lib/bundler/retry.rb' - 'lib/bundler/shared_helpers.rb' @@ -134,14 +133,13 @@ Style/AccessorMethodName: Exclude: - 'lib/bundler/source/git.rb' -# Offense count: 4 +# Offense count: 3 Style/CaseEquality: Exclude: - - 'lib/bundler/dsl.rb' - 'lib/bundler/match_platform.rb' - 'lib/bundler/rubygems_ext.rb' -# Offense count: 25 +# Offense count: 27 # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: nested, compact Style/ClassAndModuleChildren: @@ -163,11 +161,11 @@ Style/ConditionalAssignment: - 'lib/bundler/source/git.rb' - 'lib/bundler/source/rubygems.rb' -# Offense count: 158 +# Offense count: 161 Style/Documentation: Enabled: false -# Offense count: 304 +# Offense count: 308 # Cop supports --auto-correct. Style/EmptyLineAfterMagicComment: Enabled: false @@ -205,7 +203,7 @@ Style/GlobalVars: - 'lib/bundler/cli.rb' - 'spec/spec_helper.rb' -# Offense count: 17 +# Offense count: 16 # Configuration parameters: MinBodyLength. Style/GuardClause: Exclude: @@ -215,7 +213,6 @@ Style/GuardClause: - 'lib/bundler/cli/outdated.rb' - 'lib/bundler/cli/package.rb' - 'lib/bundler/definition.rb' - - 'lib/bundler/dsl.rb' - 'lib/bundler/installer.rb' - 'lib/bundler/runtime.rb' - 'lib/bundler/source/path/installer.rb' @@ -240,7 +237,7 @@ Style/IfUnlessModifierOfIfUnless: Style/IndentArray: EnforcedStyle: consistent -# Offense count: 34 +# Offense count: 35 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent @@ -361,12 +358,11 @@ Style/RaiseArgs: - 'spec/bundler/rubygems_integration_spec.rb' - 'spec/bundler/shared_helpers_spec.rb' -# Offense count: 2 +# Offense count: 1 # Cop supports --auto-correct. Style/RedundantParentheses: Exclude: - 'lib/bundler/cli/console.rb' - - 'lib/bundler/dsl.rb' # Offense count: 1 # Cop supports --auto-correct. -- cgit v1.2.1 From 7d8ae92f75fa262f466a3f0fca29e26f3af38f12 Mon Sep 17 00:00:00 2001 From: Samuel Giddins Date: Fri, 28 Apr 2017 14:43:55 +0200 Subject: [Git] Allow specifying non-branch symbolic refs --- lib/bundler/source/git/git_proxy.rb | 19 ++++---- spec/install/gemfile/git_spec.rb | 87 +++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 8 deletions(-) diff --git a/lib/bundler/source/git/git_proxy.rb b/lib/bundler/source/git/git_proxy.rb index e9b9c4dbe4..70b2d7e4f9 100644 --- a/lib/bundler/source/git/git_proxy.rb +++ b/lib/bundler/source/git/git_proxy.rb @@ -90,18 +90,21 @@ module Bundler end def checkout - if path.exist? - return if has_revision_cached? - Bundler.ui.info "Fetching #{URICredentialsFilter.credential_filtered_uri(uri)}" - in_path do - git_retry %(fetch --force --quiet --tags #{uri_escaped_with_configured_credentials} "refs/heads/*:refs/heads/*") - end - else - Bundler.ui.info "Fetching #{URICredentialsFilter.credential_filtered_uri(uri)}" + return if path.exist? && has_revision_cached? + extra_ref = "#{Shellwords.shellescape(ref)}:#{Shellwords.shellescape(ref)}" if ref && ref.start_with?("refs/") + + Bundler.ui.info "Fetching #{URICredentialsFilter.credential_filtered_uri(uri)}" + + unless path.exist? SharedHelpers.filesystem_access(path.dirname) do |p| FileUtils.mkdir_p(p) end git_retry %(clone #{uri_escaped_with_configured_credentials} "#{path}" --bare --no-hardlinks --quiet) + return unless extra_ref + end + + in_path do + git_retry %(fetch --force --quiet --tags #{uri_escaped_with_configured_credentials} "refs/heads/*:refs/heads/*" #{extra_ref}) end end diff --git a/spec/install/gemfile/git_spec.rb b/spec/install/gemfile/git_spec.rb index 8843fb7ebb..a53d96582a 100644 --- a/spec/install/gemfile/git_spec.rb +++ b/spec/install/gemfile/git_spec.rb @@ -207,6 +207,93 @@ RSpec.describe "bundle install with git sources" do expect(out).to eq("WIN") end + + it "works when the revision is a non-head ref" do + # want to ensure we don't fallback to master + update_git "foo", :path => lib_path("foo-1.0") do |s| + s.write("lib/foo.rb", "raise 'FAIL'") + end + + Dir.chdir(lib_path("foo-1.0")) do + `git update-ref -m 'Bundler Spec!' refs/bundler/1 master~1` + end + + # want to ensure we don't fallback to HEAD + update_git "foo", :path => lib_path("foo-1.0"), :branch => "rando" do |s| + s.write("lib/foo.rb", "raise 'FAIL'") + end + + install_gemfile! <<-G + git "#{lib_path("foo-1.0")}", :ref => "refs/bundler/1" do + gem "foo" + end + G + expect(err).to lack_errors + + run! <<-RUBY + require 'foo' + puts "WIN" if defined?(FOO) + RUBY + + expect(out).to eq("WIN") + end + + it "works when the revision is a non-head ref and it was previously downloaded" do + install_gemfile! <<-G + git "#{lib_path("foo-1.0")}" do + gem "foo" + end + G + + # want to ensure we don't fallback to master + update_git "foo", :path => lib_path("foo-1.0") do |s| + s.write("lib/foo.rb", "raise 'FAIL'") + end + + Dir.chdir(lib_path("foo-1.0")) do + `git update-ref -m 'Bundler Spec!' refs/bundler/1 master~1` + end + + # want to ensure we don't fallback to HEAD + update_git "foo", :path => lib_path("foo-1.0"), :branch => "rando" do |s| + s.write("lib/foo.rb", "raise 'FAIL'") + end + + install_gemfile! <<-G + git "#{lib_path("foo-1.0")}", :ref => "refs/bundler/1" do + gem "foo" + end + G + expect(err).to lack_errors + + run! <<-RUBY + require 'foo' + puts "WIN" if defined?(FOO) + RUBY + + expect(out).to eq("WIN") + end + + it "does not download random non-head refs" do + Dir.chdir(lib_path("foo-1.0")) do + `git update-ref -m 'Bundler Spec!' refs/bundler/1 master~1` + end + + install_gemfile! <<-G + git "#{lib_path("foo-1.0")}" do + gem "foo" + end + G + + # ensure we also git fetch after cloning + bundle! :update + + Dir.chdir(Dir[system_gem_path("cache/bundler/git/foo-*")].first) do + @out = sys_exec("git ls-remote .") + end + + expect(out).not_to include("refs/bundler/1") + end end describe "when specifying a branch" do -- cgit v1.2.1