tap: actively check repo visibility

We shouldn't assume that the visibility of a tap keeps unchanged by
storing it into `TapConfig`. Instead, let's actively check that to avoid
e.g. collecting unwanted analytics.

Also, speed up the check for known official public taps so that we don't
waste our GitHub API token limit in CI.
This commit is contained in:
Ruoyu Zhong 2025-08-31 22:34:30 +08:00
parent 9219495eb0
commit 78227dc924
No known key found for this signature in database

View File

@ -366,23 +366,16 @@ class Tap
return @private unless @private.nil?
@private = T.let(
if (value = config[:private]).nil?
config[:private] = begin
if custom_remote?
true
else
# Don't store config if we don't know for sure.
return false if (value = GitHub.private_repo?(full_name)).nil?
value
end
rescue GitHub::API::HTTPNotFoundError
true
rescue GitHub::API::Error
begin
if core_tap? || core_cask_tap? || OFFICIAL_CMD_TAPS.include?(name)
false
elsif custom_remote? || (value = GitHub.private_repo?(full_name)).nil?
true
else
value
end
else
value
rescue GitHub::API::Error
true
end,
T.nilable(T::Boolean),
)