dev-cmd/contributions: Simplify find_repo_path_for_repo

Co-authored-by: Rylan Polster <rslpolster@gmail.com>
This commit is contained in:
Issy Long 2022-07-24 23:18:27 +01:00
parent 503b51c54f
commit fef9a286fe
No known key found for this signature in database
GPG Key ID: 8247C390DADC67D4

View File

@ -51,7 +51,7 @@ module Homebrew
end end
repo_path = find_repo_path_for_repo(repo) repo_path = find_repo_path_for_repo(repo)
return ofail "Couldn't find repo #{repo} locally. Do you have it tapped?" unless Dir.exist?(repo_path) return ofail "Couldn't find repo #{repo} locally. Run `brew tap homebrew/#{repo}`." unless repo_path.exist?
commits += git_log_cmd("author", repo_path, args) commits += git_log_cmd("author", repo_path, args)
coauthorships += git_log_cmd("coauthorships", repo_path, args) coauthorships += git_log_cmd("coauthorships", repo_path, args)
@ -76,16 +76,9 @@ module Homebrew
sig { params(repo: String).returns(T.nilable(String)) } sig { params(repo: String).returns(T.nilable(String)) }
def find_repo_path_for_repo(repo) def find_repo_path_for_repo(repo)
case repo return HOMEBREW_REPOSITORY if repo == "brew"
when "brew"
HOMEBREW_REPOSITORY Tap.fetch("homebrew", repo).path
when "core"
"#{HOMEBREW_REPOSITORY}/Library/Taps/homebrew/homebrew-core"
when "cask"
"#{HOMEBREW_REPOSITORY}/Library/Taps/homebrew/homebrew-cask"
when "bundle"
"#{HOMEBREW_REPOSITORY}/Library/Taps/homebrew/homebrew-bundle"
end
end end
sig { params(kind: String, repo_path: String, args: Homebrew::CLI::Args).returns(Integer) } sig { params(kind: String, repo_path: String, args: Homebrew::CLI::Args).returns(Integer) }