Skip to content

Commit

Permalink
dev-cmd/contributions: Less disgusting way to determine brew's NWO
Browse files Browse the repository at this point in the history
  • Loading branch information
issyl0 committed Feb 21, 2023
1 parent d3827b1 commit 0a6c59c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions Library/Homebrew/dev-cmd/contributions.rb
Expand Up @@ -64,15 +64,21 @@ def contributions
return ofail "Unsupported repository: #{repo}. Try one of #{SUPPORTED_REPOS.join(", ")}."
end

tap = Tap.fetch("Homebrew", repo)
repo_path = find_repo_path_for_repo(repo)
tap = Tap.fetch("homebrew", repo)
unless repo_path.exist?
opoo "Repository #{repo} not yet tapped! Tapping it now..."
tap.install
end

repo_full_name = if repo == "brew"
"homebrew/brew"
else
tap.full_name
end

results[repo] = {
commits: GitHub.repo_commit_count_for_user(tap.full_name, args.named.first),
commits: GitHub.repo_commit_count_for_user(repo_full_name, args.named.first),
coauthorships: git_log_trailers_cmd(T.must(repo_path), "Co-authored-by", args),
signoffs: git_log_trailers_cmd(T.must(repo_path), "Signed-off-by", args),
}
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/tap.rb
Expand Up @@ -86,7 +86,7 @@ def self.install_default_cask_tap_if_necessary(force: false)
# e.g. `user/repo`
attr_reader :name

# The full name of this {Tap}, including the `homebrew-` prefix unless repo == "brew".
# The full name of this {Tap}, including the `homebrew-` prefix.
# It combines {#user} and 'homebrew-'-prefixed {#repo} with a slash.
# e.g. `user/homebrew-repo`
attr_reader :full_name
Expand All @@ -100,7 +100,7 @@ def initialize(user, repo)
@user = user
@repo = repo
@name = "#{@user}/#{@repo}".downcase
@full_name = (@repo == "brew") ? "#{user}/#{repo}" : "#{@user}/homebrew-#{@repo}"
@full_name = "#{@user}/homebrew-#{@repo}"
@path = TAP_DIRECTORY/@full_name.downcase
@path.extend(GitRepositoryExtension)
@alias_table = nil
Expand Down

0 comments on commit 0a6c59c

Please sign in to comment.