Skip to content

Commit

Permalink
Refactor full sha revision match logic
Browse files Browse the repository at this point in the history
  • Loading branch information
krororo committed Sep 26, 2023
1 parent a30712c commit f0d8255
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions bundler/lib/bundler/source/git/git_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,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 @@ -248,11 +248,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 f0d8255

Please sign in to comment.