utils/github: remove unnecessary chdir call

The only existing caller already has the requested directory as the
workign directory, so this is currently not needed.
This commit is contained in:
Carlo Cabrera 2023-05-17 11:39:40 +08:00
parent 05337cbb79
commit d372eb86ca
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0
2 changed files with 18 additions and 13 deletions

View File

@ -482,7 +482,7 @@ module Homebrew
ohai "Downloading bottles for workflow: #{workflow}" ohai "Downloading bottles for workflow: #{workflow}"
url = GitHub.get_artifact_url(workflow_run) url = GitHub.get_artifact_url(workflow_run)
GitHub.download_artifact(url, pr, dir) GitHub.download_artifact(url, pr)
end end
next if args.no_upload? next if args.no_upload?

View File

@ -372,7 +372,14 @@ module GitHub
artifact.last["archive_download_url"] artifact.last["archive_download_url"]
end end
def self.download_artifact(url, artifact_id, dir = Pathname.pwd) # Downloads an artifact from GitHub Actions.
#
# @param url [String] URL to download from
# @param artifact_id [String] a value that uniquely identifies the downloaded artifact
#
# @api private
sig { params(url: String, artifact_id: String).void }
def self.download_artifact(url, artifact_id)
odie "Credentials must be set to access the Artifacts API" if API.credentials_type == :none odie "Credentials must be set to access the Artifacts API" if API.credentials_type == :none
token = API.credentials token = API.credentials
@ -381,7 +388,6 @@ module GitHub
# Download the artifact as a zip file and unpack it into `dir`. This is # Download the artifact as a zip file and unpack it into `dir`. This is
# preferred over system `curl` and `tar` as this leverages the Homebrew # preferred over system `curl` and `tar` as this leverages the Homebrew
# cache to avoid repeated downloads of (possibly large) bottles. # cache to avoid repeated downloads of (possibly large) bottles.
FileUtils.chdir dir do
downloader = GitHubArtifactDownloadStrategy.new( downloader = GitHubArtifactDownloadStrategy.new(
url, url,
"artifact", "artifact",
@ -392,7 +398,6 @@ module GitHub
downloader.fetch downloader.fetch
downloader.stage downloader.stage
end end
end
def self.public_member_usernames(org, per_page: 100) def self.public_member_usernames(org, per_page: 100)
url = "#{API_URL}/orgs/#{org}/public_members" url = "#{API_URL}/orgs/#{org}/public_members"