Fix activity plugin when 0 commits are pushed

This commit is contained in:
lowlighter
2021-05-11 22:20:04 +02:00
parent 70615e77ca
commit 421a770967

View File

@@ -121,8 +121,8 @@ export default async function({login, data, rest, q, account, imports}, {enabled
//Pushed commits
case "PushEvent": {
let {size, commits, ref} = payload
if (commits[commits.length - 1].message.startsWith("Merge branch "))
commits = [commits[commits.length - 1]]
if (commits.slice(-1).pop()?.message.startsWith("Merge branch "))
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}))}
}
//Released