From fef9a286feb08c938b5f8f70403c512b50646657 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Sun, 24 Jul 2022 23:18:27 +0100 Subject: [PATCH] dev-cmd/contributions: Simplify `find_repo_path_for_repo` Co-authored-by: Rylan Polster --- Library/Homebrew/dev-cmd/contributions.rb | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/Library/Homebrew/dev-cmd/contributions.rb b/Library/Homebrew/dev-cmd/contributions.rb index b3eb9c3bc5..4a8ace15e5 100755 --- a/Library/Homebrew/dev-cmd/contributions.rb +++ b/Library/Homebrew/dev-cmd/contributions.rb @@ -51,7 +51,7 @@ module Homebrew end 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) coauthorships += git_log_cmd("coauthorships", repo_path, args) @@ -76,16 +76,9 @@ module Homebrew sig { params(repo: String).returns(T.nilable(String)) } def find_repo_path_for_repo(repo) - case repo - when "brew" - HOMEBREW_REPOSITORY - 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 + return HOMEBREW_REPOSITORY if repo == "brew" + + Tap.fetch("homebrew", repo).path end sig { params(kind: String, repo_path: String, args: Homebrew::CLI::Args).returns(Integer) }