Skip to content
Snippets Groups Projects
Commit 154237ba authored by Vinoth Ramiah's avatar Vinoth Ramiah
Browse files

fix 'cask info' for external repos with numbers

fixes 2 issues: error when username has a number, correct url for repos not on github
parent b9fe36ab
No related branches found
No related tags found
No related merge requests found
......@@ -20,7 +20,7 @@ module Hbc
puts "#{cask.token}: #{cask.version}"
puts Formatter.url(cask.homepage) if cask.homepage
installation_info(cask)
puts "From: #{Formatter.url(github_info(cask))}" if github_info(cask)
puts "From: #{Formatter.url(repo_info(cask))}" if repo_info(cask)
name_info(cask)
artifact_info(cask)
Installer.print_caveats(cask)
......@@ -50,9 +50,11 @@ module Hbc
puts cask.name.empty? ? Formatter.error("None") : cask.name
end
def self.github_info(cask)
def self.repo_info(cask)
user, repo, token = QualifiedToken.parse(Hbc.all_tokens.detect { |t| t.split("/").last == cask.token })
"#{Tap.fetch(user, repo).default_remote}/blob/master/Casks/#{token}.rb"
remote_tap = Tap.fetch(user, repo)
return "#{remote_tap.remote}" if remote_tap.custom_remote?
"#{remote_tap.default_remote}/blob/master/Casks/#{token}.rb"
end
def self.artifact_info(cask)
......
......@@ -3,7 +3,7 @@ module Hbc
REPO_PREFIX = "homebrew-".freeze
# per https://github.com/Homebrew/homebrew/blob/4c7bc9ec3bca729c898ee347b6135ba692ee0274/Library/Homebrew/cmd/tap.rb#L121
USER_REGEX = %r{[a-z_\-]+}
USER_REGEX = %r{[a-z0-9_\-]+}
# per https://github.com/Homebrew/homebrew/blob/4c7bc9ec3bca729c898ee347b6135ba692ee0274/Library/Homebrew/cmd/tap.rb#L121
REPO_REGEX = %r{(?:#{REPO_PREFIX})?\w+}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment