mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
formula_creator: Fix GitHub parsing when name doesn't match URL
The proper fix for #16675.
This commit is contained in:
parent
a6d539cf11
commit
23c2eabf9a
@ -54,10 +54,14 @@ module Homebrew
|
|||||||
|
|
||||||
case @url
|
case @url
|
||||||
when %r{github\.com/(\S+)/(\S+)\.git}
|
when %r{github\.com/(\S+)/(\S+)\.git}
|
||||||
@user = Regexp.last_match(1)
|
|
||||||
@head = true
|
@head = true
|
||||||
|
user = Regexp.last_match(1)
|
||||||
|
repo = Regexp.last_match(2)
|
||||||
|
@github = GitHub.repository(user, repo) if @fetch
|
||||||
when %r{github\.com/(\S+)/(\S+)/(archive|releases)/}
|
when %r{github\.com/(\S+)/(\S+)/(archive|releases)/}
|
||||||
@user = Regexp.last_match(1)
|
user = Regexp.last_match(1)
|
||||||
|
repo = Regexp.last_match(2)
|
||||||
|
@github = GitHub.repository(user, repo) if @fetch
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -70,26 +74,20 @@ module Homebrew
|
|||||||
|
|
||||||
if @version.nil? || @version.null?
|
if @version.nil? || @version.null?
|
||||||
odie "Version cannot be determined from URL. Explicitly set the version with `--set-version` instead."
|
odie "Version cannot be determined from URL. Explicitly set the version with `--set-version` instead."
|
||||||
elsif @fetch
|
end
|
||||||
|
|
||||||
|
if @fetch
|
||||||
unless @head
|
unless @head
|
||||||
r = Resource.new
|
r = Resource.new
|
||||||
r.url(@url)
|
r.url(@url)
|
||||||
r.version(@version)
|
|
||||||
r.owner = self
|
r.owner = self
|
||||||
@sha256 = r.fetch.sha256 if r.download_strategy == CurlDownloadStrategy
|
@sha256 = r.fetch.sha256 if r.download_strategy == CurlDownloadStrategy
|
||||||
end
|
end
|
||||||
|
|
||||||
if @user && @name
|
if @github
|
||||||
begin
|
@desc = @github["description"]
|
||||||
metadata = GitHub.repository(@user, @name)
|
@homepage = @github["homepage"]
|
||||||
@desc = metadata["description"]
|
@license = @github["license"]["spdx_id"] if @github["license"]
|
||||||
@homepage = metadata["homepage"]
|
|
||||||
@license = metadata["license"]["spdx_id"] if metadata["license"]
|
|
||||||
rescue GitHub::API::HTTPNotFoundError
|
|
||||||
# If there was no repository found assume the network connection is at
|
|
||||||
# fault rather than the input URL.
|
|
||||||
nil
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user