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

badges / shields / 45774165149

22 Nov 2026 09:43PM UTC coverage: 79.735% (-18.4%) from 98.17%
45774165149

push

github

web-flow
[Endpoint] Support message override and position it after label in API docs (#12235)

* [Endpoint] Support message override and position it after label in API docs

* Preserve error message when a message override is provided

3371 of 3616 branches covered (93.22%)

43 of 53 new or added lines in 3 files covered. (81.13%)

9589 existing lines in 490 files now uncovered.

41514 of 52065 relevant lines covered (79.73%)

51.0 hits per line

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

60.24
/services/github/github-commit-status.service.js
1
import Joi from 'joi'
2 ✔
2
import { NotFound, InvalidParameter, pathParams } from '../index.js'
2 ✔
3
import { GithubAuthV3Service } from './github-auth-service.js'
2 ✔
4
import { documentation, httpErrorsFor } from './github-helpers.js'
2 ✔
5

2 ✔
6
const schema = Joi.object({
2 ✔
7
  // https://stackoverflow.com/a/23969867/893113
2 ✔
8
  status: Joi.equal('identical', 'ahead', 'behind', 'diverged'),
2 ✔
9
}).required()
2 ✔
10

2 ✔
11
export default class GithubCommitStatus extends GithubAuthV3Service {
2 ✔
12
  static category = 'issue-tracking'
2 ✔
13
  static route = {
2 ✔
14
    base: 'github/commit-status',
2 ✔
15
    pattern: ':user/:repo/:branch/:commit',
2 ✔
16
  }
2 ✔
17

2 ✔
18
  static openApi = {
2 ✔
19
    '/github/commit-status/{user}/{repo}/{branch}/{commit}': {
2 ✔
20
      get: {
2 ✔
21
        summary: 'GitHub commit merge status',
2 ✔
22
        description: documentation,
2 ✔
23
        parameters: pathParams(
2 ✔
24
          {
2 ✔
25
            name: 'user',
2 ✔
26
            example: 'badges',
2 ✔
27
          },
2 ✔
28
          {
2 ✔
29
            name: 'repo',
2 ✔
30
            example: 'shields',
2 ✔
31
          },
2 ✔
32
          {
2 ✔
33
            name: 'branch',
2 ✔
34
            example: 'master',
2 ✔
35
          },
2 ✔
36
          {
2 ✔
37
            name: 'commit',
2 ✔
38
            example: '5d4ab86b1b5ddfb3c4a70a70bd19932c52603b8c',
2 ✔
39
          },
2 ✔
40
        ),
2 ✔
41
      },
2 ✔
42
    },
2 ✔
43
  }
2 ✔
44

2 ✔
45
  static defaultBadgeData = { label: 'commit status' }
2 ✔
46

2 ✔
47
  static render({ isInBranch, branch }) {
2 ✔
UNCOV
48
    if (isInBranch) {
×
UNCOV
49
      return {
×
UNCOV
50
        message: `in ${branch}`,
×
UNCOV
51
        color: 'brightgreen',
×
UNCOV
52
      }
×
UNCOV
53
    } else {
×
UNCOV
54
      // status: ahead or diverged
×
UNCOV
55
      return {
×
UNCOV
56
        message: `not in ${branch}`,
×
UNCOV
57
        color: 'yellow',
×
UNCOV
58
      }
×
UNCOV
59
    }
×
UNCOV
60
  }
×
61

2 ✔
62
  async handle({ user, repo, branch, commit }) {
2 ✔
UNCOV
63
    let status
×
UNCOV
64
    try {
×
UNCOV
65
      ;({ status } = await this._requestJson({
×
UNCOV
66
        url: `/repos/${user}/${repo}/compare/${branch}...${commit}`,
×
UNCOV
67
        httpErrors: httpErrorsFor('commit or branch not found'),
×
UNCOV
68
        schema,
×
UNCOV
69
      }))
×
UNCOV
70
    } catch (e) {
×
UNCOV
71
      if (e instanceof NotFound) {
×
UNCOV
72
        const { message } = this._parseJson(e.buffer)
×
UNCOV
73
        if (message && message.startsWith('No common ancestor between')) {
×
UNCOV
74
          throw new InvalidParameter({ prettyMessage: 'no common ancestor' })
×
UNCOV
75
        }
×
UNCOV
76
      }
×
UNCOV
77
      throw e
×
UNCOV
78
    }
×
UNCOV
79

×
UNCOV
80
    const isInBranch = status === 'identical' || status === 'behind'
×
UNCOV
81
    return this.constructor.render({ isInBranch, branch })
×
UNCOV
82
  }
×
83
}
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