• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

badges / shields / 39217188618

18 Oct 2026 11:42PM UTC coverage: 79.763% (-18.4%) from 98.173%
39217188618

push

github

web-flow
Update simple-icons to 16.35.0 (#12233)

Co-authored-by: github-merge-queue <118344674+github-merge-queue@users.noreply.github.com>

3358 of 3601 branches covered (93.25%)

41381 of 51880 relevant lines covered (79.76%)

50.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.11
/services/github/github-last-commit.service.js
1
import Joi from 'joi'
2 ✔
2
import { renderDateBadge } from '../date.js'
2 ✔
3
import { NotFound, pathParam, queryParam } from '../index.js'
2 ✔
4
import { relativeUri } from '../validators.js'
2 ✔
5
import { GithubAuthV3Service } from './github-auth-service.js'
2 ✔
6
import { documentation, httpErrorsFor } from './github-helpers.js'
2 ✔
7

2 ✔
8
const schema = Joi.array()
2 ✔
9
  .items(
2 ✔
10
    Joi.object({
2 ✔
11
      commit: Joi.object({
2 ✔
12
        author: Joi.object({
2 ✔
13
          date: Joi.string().required(),
2 ✔
14
        }).required(),
2 ✔
15
        committer: Joi.object({
2 ✔
16
          date: Joi.string().required(),
2 ✔
17
        }).required(),
2 ✔
18
      }).required(),
2 ✔
19
    }),
2 ✔
20
  )
2 ✔
21
  .required()
2 ✔
22

2 ✔
23
const displayEnum = ['author', 'committer']
2 ✔
24

2 ✔
25
const queryParamSchema = Joi.object({
2 ✔
26
  path: relativeUri,
2 ✔
27
  display_timestamp: Joi.string()
2 ✔
28
    .valid(...displayEnum)
2 ✔
29
    .default('author'),
2 ✔
30
}).required()
2 ✔
31

2 ✔
32
export default class GithubLastCommit extends GithubAuthV3Service {
2 ✔
33
  static category = 'activity'
2 ✔
34
  static route = {
2 ✔
35
    base: 'github/last-commit',
2 ✔
36
    pattern: ':user/:repo/:branch*',
2 ✔
37
    queryParamSchema,
2 ✔
38
  }
2 ✔
39

2 ✔
40
  static openApi = {
2 ✔
41
    '/github/last-commit/{user}/{repo}': {
2 ✔
42
      get: {
2 ✔
43
        summary: 'GitHub last commit',
2 ✔
44
        description: documentation,
2 ✔
45
        parameters: [
2 ✔
46
          pathParam({ name: 'user', example: 'google' }),
2 ✔
47
          pathParam({ name: 'repo', example: 'skia' }),
2 ✔
48
          queryParam({
2 ✔
49
            name: 'path',
2 ✔
50
            example: 'README.md',
2 ✔
51
            schema: { type: 'string' },
2 ✔
52
            description: 'File path to resolve the last commit for.',
2 ✔
53
          }),
2 ✔
54
          queryParam({
2 ✔
55
            name: 'display_timestamp',
2 ✔
56
            example: 'committer',
2 ✔
57
            schema: { type: 'string', enum: displayEnum },
2 ✔
58
            description: 'Defaults to `author` if not specified',
2 ✔
59
          }),
2 ✔
60
        ],
2 ✔
61
      },
2 ✔
62
    },
2 ✔
63
    '/github/last-commit/{user}/{repo}/{branch}': {
2 ✔
64
      get: {
2 ✔
65
        summary: 'GitHub last commit (branch)',
2 ✔
66
        description: documentation,
2 ✔
67
        parameters: [
2 ✔
68
          pathParam({ name: 'user', example: 'google' }),
2 ✔
69
          pathParam({ name: 'repo', example: 'skia' }),
2 ✔
70
          pathParam({ name: 'branch', example: 'infra/config' }),
2 ✔
71
          queryParam({
2 ✔
72
            name: 'path',
2 ✔
73
            example: 'README.md',
2 ✔
74
            schema: { type: 'string' },
2 ✔
75
            description: 'File path to resolve the last commit for.',
2 ✔
76
          }),
2 ✔
77
          queryParam({
2 ✔
78
            name: 'display_timestamp',
2 ✔
79
            example: 'committer',
2 ✔
80
            schema: { type: 'string', enum: displayEnum },
2 ✔
81
            description: 'Defaults to `author` if not specified',
2 ✔
82
          }),
2 ✔
83
        ],
2 ✔
84
      },
2 ✔
85
    },
2 ✔
86
  }
2 ✔
87

2 ✔
88
  static defaultBadgeData = { label: 'last commit' }
2 ✔
89

2 ✔
90
  async fetch({ user, repo, branch, path }) {
2 ✔
91
    return this._requestJson({
×
92
      url: `/repos/${user}/${repo}/commits`,
×
93
      options: { searchParams: { sha: branch, path, per_page: 1 } },
×
94
      schema,
×
95
      httpErrors: httpErrorsFor(),
×
96
    })
×
97
  }
×
98

2 ✔
99
  async handle({ user, repo, branch }, queryParams) {
2 ✔
100
    const { path, display_timestamp: displayTimestamp } = queryParams
×
101
    const body = await this.fetch({ user, repo, branch, path })
×
102
    const [commit] = body.map(obj => obj.commit)
×
103

×
104
    if (!commit) throw new NotFound({ prettyMessage: 'no commits found' })
×
105

×
106
    return renderDateBadge(commit[displayTimestamp].date)
×
107
  }
×
108
}
2 ✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc