From da1369e71fcdae85f3b05ffd8e3c9602f89c7544 Mon Sep 17 00:00:00 2001 From: Luke Massa Date: Sun, 18 Jun 2023 14:12:23 -0400 Subject: [PATCH 1/5] feat(plugin-git): remove duplicate no-reply contributors --- .../plugin-git/src/node/utils/getContributors.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ecosystem/plugin-git/src/node/utils/getContributors.ts b/ecosystem/plugin-git/src/node/utils/getContributors.ts index b875f373ac..977699d1fa 100644 --- a/ecosystem/plugin-git/src/node/utils/getContributors.ts +++ b/ecosystem/plugin-git/src/node/utils/getContributors.ts @@ -23,4 +23,17 @@ export const getContributors = async ( email, commits: Number.parseInt(commits, 10), })) + .filter((item, index, self) => { + // If one of the contributors is a "noreply" email address, *and* there's + // already a contributor *with the same name*, it is very likely a duplicate, + // so it can be removed. + if ( + item.email.includes('@') && + (item.email.split('@')[1].includes('noreply') || + item.email.split('@')[1].includes('no-reply')) + ) { + return index === self.findIndex((t) => t.name === item.name) + } + return true + }) } From b40a014ab2e69a13f526e42ba1c2806f92338f5c Mon Sep 17 00:00:00 2001 From: Xinyu Liu Date: Thu, 6 Jul 2023 13:38:39 +0800 Subject: [PATCH 2/5] Update getContributors.ts --- ecosystem/plugin-git/src/node/utils/getContributors.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/ecosystem/plugin-git/src/node/utils/getContributors.ts b/ecosystem/plugin-git/src/node/utils/getContributors.ts index 977699d1fa..91503358b2 100644 --- a/ecosystem/plugin-git/src/node/utils/getContributors.ts +++ b/ecosystem/plugin-git/src/node/utils/getContributors.ts @@ -27,11 +27,7 @@ export const getContributors = async ( // If one of the contributors is a "noreply" email address, *and* there's // already a contributor *with the same name*, it is very likely a duplicate, // so it can be removed. - if ( - item.email.includes('@') && - (item.email.split('@')[1].includes('noreply') || - item.email.split('@')[1].includes('no-reply')) - ) { + if (item.email.split('@')[1]?.match(/no-?reply/')) { return index === self.findIndex((t) => t.name === item.name) } return true From 04ac7b09c35434f25c096baeddfc16931c677276 Mon Sep 17 00:00:00 2001 From: Xinyu Liu Date: Thu, 6 Jul 2023 13:39:05 +0800 Subject: [PATCH 3/5] Update getContributors.ts --- ecosystem/plugin-git/src/node/utils/getContributors.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecosystem/plugin-git/src/node/utils/getContributors.ts b/ecosystem/plugin-git/src/node/utils/getContributors.ts index 91503358b2..6e4342252c 100644 --- a/ecosystem/plugin-git/src/node/utils/getContributors.ts +++ b/ecosystem/plugin-git/src/node/utils/getContributors.ts @@ -27,7 +27,7 @@ export const getContributors = async ( // If one of the contributors is a "noreply" email address, *and* there's // already a contributor *with the same name*, it is very likely a duplicate, // so it can be removed. - if (item.email.split('@')[1]?.match(/no-?reply/')) { + if (item.email.split('@')[1]?.match(/no-?reply/)) { return index === self.findIndex((t) => t.name === item.name) } return true From aa5d24c300b59e8bf2a51373ebf8a8ebd3d2e9c5 Mon Sep 17 00:00:00 2001 From: Luke Massa Date: Sat, 8 Jul 2023 16:40:29 -0400 Subject: [PATCH 4/5] feat(plugin-git): merge contribution numbers for duplicates --- ecosystem/plugin-git/src/node/utils/getContributors.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ecosystem/plugin-git/src/node/utils/getContributors.ts b/ecosystem/plugin-git/src/node/utils/getContributors.ts index 6e4342252c..88ec6b3931 100644 --- a/ecosystem/plugin-git/src/node/utils/getContributors.ts +++ b/ecosystem/plugin-git/src/node/utils/getContributors.ts @@ -28,7 +28,13 @@ export const getContributors = async ( // already a contributor *with the same name*, it is very likely a duplicate, // so it can be removed. if (item.email.split('@')[1]?.match(/no-?reply/)) { - return index === self.findIndex((t) => t.name === item.name) + const realIndex = self.findIndex((t) => t.name === item.name) + if (realIndex !== index) { + // Before filtering, update the "real" contributor to also include the noreply's commits + self[realIndex].commits += item.commits + return false + } + return true } return true }) From c38f70395c70492356b54d11285d49b41482e5ca Mon Sep 17 00:00:00 2001 From: Xinyu Liu Date: Tue, 11 Jul 2023 19:36:24 +0800 Subject: [PATCH 5/5] Update getContributors.ts --- ecosystem/plugin-git/src/node/utils/getContributors.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ecosystem/plugin-git/src/node/utils/getContributors.ts b/ecosystem/plugin-git/src/node/utils/getContributors.ts index 88ec6b3931..ef5fbbb2db 100644 --- a/ecosystem/plugin-git/src/node/utils/getContributors.ts +++ b/ecosystem/plugin-git/src/node/utils/getContributors.ts @@ -24,13 +24,13 @@ export const getContributors = async ( commits: Number.parseInt(commits, 10), })) .filter((item, index, self) => { - // If one of the contributors is a "noreply" email address, *and* there's - // already a contributor *with the same name*, it is very likely a duplicate, + // If one of the contributors is a "noreply" email address, and there's + // already a contributor with the same name, it is very likely a duplicate, // so it can be removed. if (item.email.split('@')[1]?.match(/no-?reply/)) { const realIndex = self.findIndex((t) => t.name === item.name) if (realIndex !== index) { - // Before filtering, update the "real" contributor to also include the noreply's commits + // Update the "real" contributor to also include the noreply's commits self[realIndex].commits += item.commits return false }