Merge pull request #20018 from koddsson/fetch-repo-before-asserting-default-branch

tap: fix handling of `--repair` with no branches
This commit is contained in:
Bo Anderson 2025-05-27 17:11:00 +00:00 committed by GitHub
commit fe3783d711
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -590,8 +590,9 @@ class Tap
end end
return unless remote return unless remote
current_upstream_head = T.must(git_repository.origin_branch_name) current_upstream_head = git_repository.origin_branch_name
return if requested_remote.blank? && git_repository.origin_has_branch?(current_upstream_head) return if current_upstream_head.present? && requested_remote.blank? &&
git_repository.origin_has_branch?(current_upstream_head)
args = %w[fetch] args = %w[fetch]
args << "--quiet" if quiet args << "--quiet" if quiet
@ -600,6 +601,8 @@ class Tap
safe_system "git", "-C", path, *args safe_system "git", "-C", path, *args
git_repository.set_head_origin_auto git_repository.set_head_origin_auto
current_upstream_head ||= T.must(git_repository.origin_branch_name)
new_upstream_head = T.must(git_repository.origin_branch_name) new_upstream_head = T.must(git_repository.origin_branch_name)
return if new_upstream_head == current_upstream_head return if new_upstream_head == current_upstream_head