dev-cmd/contributions: Less disgusting way to determine brew's NWO

This commit is contained in:
Issy Long 2023-02-21 00:48:46 +00:00
parent d3827b12f2
commit 0a6c59c0b3
No known key found for this signature in database
GPG Key ID: 8247C390DADC67D4
2 changed files with 10 additions and 4 deletions

View File

@ -64,15 +64,21 @@ module Homebrew
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),
}

View File

@ -86,7 +86,7 @@ class Tap
# 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
@ -100,7 +100,7 @@ class Tap
@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