mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Memoize GitHubGitDownloadStrategy#default_branch
and then remove `yield_self` from `default_refspec` in favor of relying on `default_branch`'s memoization
This commit is contained in:
parent
b7426b4d51
commit
dd3b0d244f
@ -1078,17 +1078,17 @@ class GitHubGitDownloadStrategy < GitDownloadStrategy
|
||||
|
||||
sig { returns(String) }
|
||||
def default_refspec
|
||||
default_branch.yield_self do |branch|
|
||||
if branch
|
||||
"+refs/heads/#{branch}:refs/remotes/origin/#{branch}"
|
||||
if default_branch
|
||||
"+refs/heads/#{default_branch}:refs/remotes/origin/#{default_branch}"
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
sig { returns(String) }
|
||||
def default_branch
|
||||
return @default_branch if defined?(@default_branch)
|
||||
|
||||
command! "git",
|
||||
args: ["remote", "set-head", "origin", "--auto"],
|
||||
chdir: cached_location
|
||||
@ -1097,7 +1097,7 @@ class GitHubGitDownloadStrategy < GitDownloadStrategy
|
||||
args: ["symbolic-ref", "refs/remotes/origin/HEAD"],
|
||||
chdir: cached_location
|
||||
|
||||
result.stdout[%r{^refs/remotes/origin/(.*)$}, 1]
|
||||
@default_branch = result.stdout[%r{^refs/remotes/origin/(.*)$}, 1]
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user