Skip to content

Commit

Permalink
[rubygems/rubygems] Refactor full sha revision match logic
Browse files Browse the repository at this point in the history
  • Loading branch information
krororo authored and matzbot committed Sep 27, 2023
1 parent fbee93f commit bc66460
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/bundler/source/git/git_proxy.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit bc66460

Please sign in to comment.