master
 1import { Commit, define, Repository, plural } from '#src'
 2
 3export default define({
 4  url: import.meta.url,
 5  badges: ['dead-commit'] as const,
 6  present(data, grant) {
 7    const commits: { repo: Repository; commit: Commit }[] = []
 8
 9    for (const repo of data.repos) {
10      for (const commit of repo.commits) {
11        if (commit.sha.includes('dead')) {
12          commits.push({ repo, commit })
13        }
14      }
15    }
16
17    const text = commits
18      .map(({ repo, commit }) => {
19        const sha = commit.sha.replace(/dead/, '<strong>dead</strong>')
20        return `- <a href="https://github.com/${repo.owner.login}/${repo.name}/commit/${commit.sha}">${sha}</a>`
21      })
22      .join('\n')
23
24    if (commits.length >= 1) {
25      grant(
26        'dead-commit',
27        `I pushed a commit with "dead" ${plural(
28          commits.length,
29          'once',
30          '%d times',
31        )}.`,
32      ).evidence(text)
33    }
34  },
35})