feat(app/metrics): support ignoring users by email for commits related elements (#890)
This commit is contained in:
@@ -137,6 +137,9 @@ export default async function({login, data, rest, q, account, imports}, {enabled
|
|||||||
//Pushed commits
|
//Pushed commits
|
||||||
case "PushEvent": {
|
case "PushEvent": {
|
||||||
let {size, commits, ref} = payload
|
let {size, commits, ref} = payload
|
||||||
|
commits = commits.filter(({author:{email}}) => !ignored.includes(email))
|
||||||
|
if (!commits.length)
|
||||||
|
return null
|
||||||
if (commits.slice(-1).pop()?.message.startsWith("Merge branch "))
|
if (commits.slice(-1).pop()?.message.startsWith("Merge branch "))
|
||||||
commits = commits.slice(-1)
|
commits = commits.slice(-1)
|
||||||
return {type:"push", actor, timestamp, repo, size, branch:ref.match(/refs.heads.(?<branch>.*)/)?.groups?.branch ?? null, commits:commits.reverse().map(({sha, message}) => ({sha:sha.substring(0, 7), message}))}
|
return {type:"push", actor, timestamp, repo, size, branch:ref.match(/refs.heads.(?<branch>.*)/)?.groups?.branch ?? null, commits:commits.reverse().map(({sha, message}) => ({sha:sha.substring(0, 7), message}))}
|
||||||
|
|||||||
@@ -88,10 +88,13 @@ inputs:
|
|||||||
global: yes
|
global: yes
|
||||||
|
|
||||||
users_ignored:
|
users_ignored:
|
||||||
description: Default ignored users
|
description: |
|
||||||
|
Default ignored users
|
||||||
|
|
||||||
|
Note that email are supported only commits-related elements.
|
||||||
type: array
|
type: array
|
||||||
format: comma-separated
|
format: comma-separated
|
||||||
default: github-actions[bot], dependabot[bot], dependabot-preview[bot], actions-user
|
default: github-actions[bot], dependabot[bot], dependabot-preview[bot], actions-user, action@github.com
|
||||||
global: yes
|
global: yes
|
||||||
|
|
||||||
commits_authoring:
|
commits_authoring:
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export default async function({login, q, imports, data, rest, graphql, queries,
|
|||||||
//Load inputs
|
//Load inputs
|
||||||
let {head, base, ignored, contributions, sections, categories} = imports.metadata.plugins.contributors.inputs({data, account, q})
|
let {head, base, ignored, contributions, sections, categories} = imports.metadata.plugins.contributors.inputs({data, account, q})
|
||||||
const repo = {owner:data.repo.owner.login, repo:data.repo.name}
|
const repo = {owner:data.repo.owner.login, repo:data.repo.name}
|
||||||
|
ignored.push(...data.shared["users.ignored"])
|
||||||
|
|
||||||
//Retrieve head and base commits
|
//Retrieve head and base commits
|
||||||
console.debug(`metrics/compute/${login}/plugins > contributors > querying api head and base commits`)
|
console.debug(`metrics/compute/${login}/plugins > contributors > querying api head and base commits`)
|
||||||
@@ -49,8 +50,8 @@ export default async function({login, q, imports, data, rest, graphql, queries,
|
|||||||
|
|
||||||
//Compute contributors and contributions
|
//Compute contributors and contributions
|
||||||
let contributors = {}
|
let contributors = {}
|
||||||
for (const {author:{login, avatar_url:avatar}, commit:{message = ""}} of commits) {
|
for (const {author:{login, avatar_url:avatar}, commit:{message = "", author:{email = ""} = {}}} of commits) {
|
||||||
if ((!login) || (ignored.includes(login))) {
|
if ((!login) || (ignored.includes(login)) || (ignored.includes(email))) {
|
||||||
console.debug(`metrics/compute/${login}/plugins > contributors > ignored contributor "${login}"`)
|
console.debug(`metrics/compute/${login}/plugins > contributors > ignored contributor "${login}"`)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user