chore: code formatting

This commit is contained in:
github-actions[bot]
2022-04-23 23:18:43 +00:00
parent 73cd43c18f
commit 4c98629bbc
130 changed files with 1839 additions and 1788 deletions

View File

@@ -8,23 +8,23 @@ export default async function({login, q, imports, data, rest, graphql, queries,
//Load inputs
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
console.debug(`metrics/compute/${login}/plugins > contributors > querying api head and base commits`)
const ref = {
head:(await graphql(queries.contributors.commit({...repo, expression:head}))).repository.object,
base:(await graphql(queries.contributors.commit({...repo, expression:base}))).repository.object,
head: (await graphql(queries.contributors.commit({...repo, expression: head}))).repository.object,
base: (await graphql(queries.contributors.commit({...repo, expression: base}))).repository.object,
}
//Get commit activity
console.debug(`metrics/compute/${login}/plugins > contributors > querying api for commits between [${ref.base?.abbreviatedOid ?? null}] and [${ref.head?.abbreviatedOid ?? null}]`)
const commits = []
for (let page = 1; ; page++) {
for (let page = 1;; page++) {
console.debug(`metrics/compute/${login}/plugins > contributors > loading page ${page}`)
try {
const {data:loaded} = await rest.repos.listCommits({...repo, per_page:100, page})
const {data: loaded} = await rest.repos.listCommits({...repo, per_page: 100, page})
if (loaded.map(({sha}) => sha).includes(ref.base?.oid)) {
console.debug(`metrics/compute/${login}/plugins > contributors > reached ${ref.base?.oid}`)
commits.push(...loaded.slice(0, loaded.map(({sha}) => sha).indexOf(ref.base.oid)))
@@ -50,13 +50,13 @@ export default async function({login, q, imports, data, rest, graphql, queries,
//Compute contributors and contributions
let contributors = {}
for (const {author:{login, avatar_url:avatar}, commit:{message = "", author:{email = ""} = {}}} of commits) {
for (const {author: {login, avatar_url: avatar}, commit: {message = "", author: {email = ""} = {}}} of commits) {
if ((!login) || (ignored.includes(login)) || (ignored.includes(email))) {
console.debug(`metrics/compute/${login}/plugins > contributors > ignored contributor "${login}"`)
continue
}
if (!(login in contributors))
contributors[login] = {avatar:await imports.imgb64(avatar), contributions:1, pr:[]}
contributors[login] = {avatar: await imports.imgb64(avatar), contributions: 1, pr: []}
else {
contributors[login].contributions++
contributors[login].pr.push(...(message.match(/(?<=[(])#\d+(?=[)])/g) ?? []))
@@ -78,8 +78,8 @@ export default async function({login, q, imports, data, rest, graphql, queries,
try {
//Git clone into temporary directory
await imports.fs.rm(path, {recursive:true, force:true})
await imports.fs.mkdir(path, {recursive:true})
await imports.fs.rm(path, {recursive: true, force: true})
await imports.fs.mkdir(path, {recursive: true})
const git = await imports.git(path)
await git.clone(`https://github.com/${repository}`, ".").status()
@@ -87,7 +87,7 @@ export default async function({login, q, imports, data, rest, graphql, queries,
for (const contributor in contributors) {
//Load edited files by contributor
const files = []
await imports.spawn("git", ["--no-pager", "log", `--author="${contributor}"`, "--regexp-ignore-case", "--no-merges", "--name-only", '--pretty=format:""'], {cwd:path}, {
await imports.spawn("git", ["--no-pager", "log", `--author="${contributor}"`, "--regexp-ignore-case", "--no-merges", "--name-only", '--pretty=format:""'], {cwd: path}, {
stdout(line) {
if (line.trim().length)
files.push(line)
@@ -98,7 +98,7 @@ export default async function({login, q, imports, data, rest, graphql, queries,
for (const file of files) {
for (const [category, globs] of Object.entries(categories)) {
for (const glob of [globs].flat(Infinity)) {
if (imports.minimatch(file, glob, {nocase:true})) {
if (imports.minimatch(file, glob, {nocase: true})) {
types[category].add(contributor)
continue filesloop
}
@@ -114,15 +114,15 @@ export default async function({login, q, imports, data, rest, graphql, queries,
finally {
//Cleaning
console.debug(`metrics/compute/${login}/plugins > contributors > cleaning temp dir ${path}`)
await imports.fs.rm(path, {recursive:true, force:true})
await imports.fs.rm(path, {recursive: true, force: true})
}
}
//Results
return {head, base, ref, list:contributors, categories:types, contributions, sections}
return {head, base, ref, list: contributors, categories: types, contributions, sections}
}
//Handle errors
catch (error) {
throw {error:{message:"An error occured", instance:error}}
throw {error: {message: "An error occured", instance: error}}
}
}