From 693d609730e5f20c0347000850583506c825abae Mon Sep 17 00:00:00 2001 From: Issy Long Date: Fri, 3 Mar 2023 13:15:13 +0000 Subject: [PATCH] dev-cmd/contributions: Fix authored vs. committed commit uniqueness - For a situation where `authored = 3`, `committed = 4`, the previous calculation was `3 - 4` which meant that `committed = -1` in the end. - This was incorrect, since a user can't have negative contributions! - Instead, only do the subtraction to get the deduplicated `committed` count if the number of authored commits is higher than the number of committed commits. This approach should achieve the desired "don't double count things that the user authored and committed, but do count things that another person authored that the user committed". --- Library/Homebrew/dev-cmd/contributions.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Library/Homebrew/dev-cmd/contributions.rb b/Library/Homebrew/dev-cmd/contributions.rb index ed4a8d2138..9fe19f8b59 100755 --- a/Library/Homebrew/dev-cmd/contributions.rb +++ b/Library/Homebrew/dev-cmd/contributions.rb @@ -174,9 +174,7 @@ module Homebrew commits_authored = GitHub.repo_commit_count_for_user(repo_full_name, person, "author", args) commits_committed = GitHub.repo_commit_count_for_user(repo_full_name, person, "committer", args) # Only count committers where the author is not the same person. Avoid negative numbers or subtracting zero. - if commits_authored.positive? && commits_committed.positive? - commits_committed = commits_authored - commits_committed - end + commits_committed = commits_authored - commits_committed if commits_authored > commits_committed data[repo] = { author: commits_authored,