From c65d7b4bea170ffe4811534ab33b231f7f57d69f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Thu, 9 Mar 2023 17:34:17 +0100 Subject: When running `bundle lock --update `, checkout locked revision of unrelated git sources directly Since Bundler 2.4, we will try to checkout any branch specified in the Gemfile, while until Bundler 2.3 we would directly checkout the locked revision. This should not make any difference in most situations, but in some edge cases, like if the branch specified in the `Gemfile` has been renamed, but the locked revision still exist, it causes an error now while before it would update the lockfile without issues. I debated which behavior was best, since I was not sure. But my conclusion is that if the situation does not require expiring the lockfile source in favor of the Gemfile source, we should use the locked revision directly and proceed happily. So I restored Bundler 2.3 behavior. I think this is consistent with how yanked gems are handled, for example. Of course, if explicitly updating the git source itself, or all gems, we will still get any errors like missing branches related to the git source. --- lib/bundler/source/git/git_proxy.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/bundler/source/git') diff --git a/lib/bundler/source/git/git_proxy.rb b/lib/bundler/source/git/git_proxy.rb index 3a6a666627..926c9b8ead 100644 --- a/lib/bundler/source/git/git_proxy.rb +++ b/lib/bundler/source/git/git_proxy.rb @@ -366,6 +366,11 @@ module Bundler args += ["--single-branch"] args.unshift("--no-tags") if supports_cloning_with_no_tags? + # If there's a locked revision, no need to clone any specific branch + # or tag, since we will end up checking out that locked revision + # anyways. + return args if @revision + args += ["--branch", branch || tag] if branch || tag args end -- cgit v1.2.3