From bc664609df6a5dfb95bc9c604bd0a661b3fbcf26 Mon Sep 17 00:00:00 2001 From: krororo Date: Tue, 26 Sep 2023 09:58:20 +0900 Subject: [PATCH] [rubygems/rubygems] Refactor full sha revision match logic https://github.com/rubygems/rubygems/commit/f0d8255ebd --- lib/bundler/source/git/git_proxy.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/bundler/source/git/git_proxy.rb b/lib/bundler/source/git/git_proxy.rb index 49223213435846..bb3ca062c37b75 100644 --- a/lib/bundler/source/git/git_proxy.rb +++ b/lib/bundler/source/git/git_proxy.rb @@ -118,7 +118,7 @@ def copy_to(destination, submodules = false) end end - ref = @commit_ref || (full_sha_revision? && @revision) + ref = @commit_ref || (locked_to_full_sha? && @revision) git "fetch", "--force", "--quiet", *extra_fetch_args(ref), :dir => destination if ref git "reset", "--hard", @revision, :dir => destination @@ -236,11 +236,15 @@ def not_pinned? end def pinned_to_full_sha? - ref =~ /\A\h{40}\z/ + full_sha_revision?(ref) end - def full_sha_revision? - @revision.match?(/\A\h{40}\z/) + def locked_to_full_sha? + full_sha_revision?(@revision) + end + + def full_sha_revision?(ref) + ref&.match?(/\A\h{40}\z/) end def git_null(*command, dir: nil)