feat: add [gitlab]-helper for encapsulate docs and err (#8295)
* feat: add gitlab-helper for encapsulate docs and err * update merge requests * fix mr example Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import Joi from 'joi'
|
import Joi from 'joi'
|
||||||
import { optionalUrl, nonNegativeInteger } from '../validators.js'
|
import { optionalUrl, nonNegativeInteger } from '../validators.js'
|
||||||
import { renderContributorBadge } from '../contributor-count.js'
|
import { renderContributorBadge } from '../contributor-count.js'
|
||||||
|
import { documentation, errorMessagesFor } from './gitlab-helper.js'
|
||||||
import GitLabBase from './gitlab-base.js'
|
import GitLabBase from './gitlab-base.js'
|
||||||
|
|
||||||
const schema = Joi.object({ 'x-total': nonNegativeInteger }).required()
|
const schema = Joi.object({ 'x-total': nonNegativeInteger }).required()
|
||||||
@@ -9,19 +10,6 @@ const queryParamSchema = Joi.object({
|
|||||||
gitlab_url: optionalUrl,
|
gitlab_url: optionalUrl,
|
||||||
}).required()
|
}).required()
|
||||||
|
|
||||||
const documentation = `
|
|
||||||
<p>
|
|
||||||
You may use your GitLab Project Id (e.g. 278964) or your Project Path (e.g. gitlab-org/gitlab )
|
|
||||||
</p>
|
|
||||||
`
|
|
||||||
|
|
||||||
const customDocumentation = `
|
|
||||||
<p>
|
|
||||||
Note that only network-accessible jihulab.com and other self-managed GitLab instances are supported.
|
|
||||||
You may use your GitLab Project Id (e.g. 13953) or your Project Path (e.g. gitlab-cn/gitlab ) in <a href="https://jihulab.com">https://jihulab.com</a>
|
|
||||||
</p>
|
|
||||||
`
|
|
||||||
|
|
||||||
export default class GitlabContributors extends GitLabBase {
|
export default class GitlabContributors extends GitLabBase {
|
||||||
static category = 'activity'
|
static category = 'activity'
|
||||||
static route = {
|
static route = {
|
||||||
@@ -46,7 +34,7 @@ export default class GitlabContributors extends GitLabBase {
|
|||||||
project: 'gitlab-cn/gitlab',
|
project: 'gitlab-cn/gitlab',
|
||||||
},
|
},
|
||||||
staticPreview: this.render({ contributorCount: 415 }),
|
staticPreview: this.render({ contributorCount: 415 }),
|
||||||
documentation: customDocumentation,
|
documentation,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -64,9 +52,7 @@ export default class GitlabContributors extends GitLabBase {
|
|||||||
project
|
project
|
||||||
)}/repository/contributors`,
|
)}/repository/contributors`,
|
||||||
options: { searchParams: { page: '1', per_page: '1' } },
|
options: { searchParams: { page: '1', per_page: '1' } },
|
||||||
errorMessages: {
|
errorMessages: errorMessagesFor('project not found'),
|
||||||
404: 'project not found',
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
const data = this.constructor._validate(res.headers, schema)
|
const data = this.constructor._validate(res.headers, schema)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import Joi from 'joi'
|
|||||||
import { coveragePercentage } from '../color-formatters.js'
|
import { coveragePercentage } from '../color-formatters.js'
|
||||||
import { optionalUrl } from '../validators.js'
|
import { optionalUrl } from '../validators.js'
|
||||||
import { BaseSvgScrapingService, NotFound } from '../index.js'
|
import { BaseSvgScrapingService, NotFound } from '../index.js'
|
||||||
|
import { documentation, errorMessagesFor } from './gitlab-helper.js'
|
||||||
|
|
||||||
const schema = Joi.object({
|
const schema = Joi.object({
|
||||||
message: Joi.string()
|
message: Joi.string()
|
||||||
@@ -14,7 +15,7 @@ const queryParamSchema = Joi.object({
|
|||||||
job_name: Joi.string(),
|
job_name: Joi.string(),
|
||||||
}).required()
|
}).required()
|
||||||
|
|
||||||
const documentation = `
|
const moreDocs = `
|
||||||
<p>
|
<p>
|
||||||
Important: If your project is publicly visible, but the badge is like this:
|
Important: If your project is publicly visible, but the badge is like this:
|
||||||
<img src="https://img.shields.io/badge/coverage-not set up-red" alt="coverage not set up"/>
|
<img src="https://img.shields.io/badge/coverage-not set up-red" alt="coverage not set up"/>
|
||||||
@@ -54,7 +55,7 @@ export default class GitlabCoverage extends BaseSvgScrapingService {
|
|||||||
branch: 'master',
|
branch: 'master',
|
||||||
},
|
},
|
||||||
staticPreview: this.render({ coverage: 67 }),
|
staticPreview: this.render({ coverage: 67 }),
|
||||||
documentation,
|
documentation: documentation + moreDocs,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Gitlab code coverage (specific job)',
|
title: 'Gitlab code coverage (specific job)',
|
||||||
@@ -65,14 +66,14 @@ export default class GitlabCoverage extends BaseSvgScrapingService {
|
|||||||
},
|
},
|
||||||
queryParams: { job_name: 'test coverage report' },
|
queryParams: { job_name: 'test coverage report' },
|
||||||
staticPreview: this.render({ coverage: 96 }),
|
staticPreview: this.render({ coverage: 96 }),
|
||||||
documentation,
|
documentation: documentation + moreDocs,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Gitlab code coverage (self-managed)',
|
title: 'Gitlab code coverage (self-managed)',
|
||||||
namedParams: { user: 'GNOME', repo: 'at-spi2-core', branch: 'master' },
|
namedParams: { user: 'GNOME', repo: 'at-spi2-core', branch: 'master' },
|
||||||
queryParams: { gitlab_url: 'https://gitlab.gnome.org' },
|
queryParams: { gitlab_url: 'https://gitlab.gnome.org' },
|
||||||
staticPreview: this.render({ coverage: 93 }),
|
staticPreview: this.render({ coverage: 93 }),
|
||||||
documentation,
|
documentation: documentation + moreDocs,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Gitlab code coverage (self-managed, specific job)',
|
title: 'Gitlab code coverage (self-managed, specific job)',
|
||||||
@@ -82,7 +83,7 @@ export default class GitlabCoverage extends BaseSvgScrapingService {
|
|||||||
job_name: 'unit-test',
|
job_name: 'unit-test',
|
||||||
},
|
},
|
||||||
staticPreview: this.render({ coverage: 93 }),
|
staticPreview: this.render({ coverage: 93 }),
|
||||||
documentation,
|
documentation: documentation + moreDocs,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -100,10 +101,7 @@ export default class GitlabCoverage extends BaseSvgScrapingService {
|
|||||||
// it is recommended to not use the query param at all if not required
|
// it is recommended to not use the query param at all if not required
|
||||||
jobName = jobName ? `?job=${jobName}` : ''
|
jobName = jobName ? `?job=${jobName}` : ''
|
||||||
const url = `${baseUrl}/${user}/${repo}/badges/${branch}/coverage.svg${jobName}`
|
const url = `${baseUrl}/${user}/${repo}/badges/${branch}/coverage.svg${jobName}`
|
||||||
const errorMessages = {
|
const errorMessages = errorMessagesFor('project not found')
|
||||||
401: 'repo not found',
|
|
||||||
404: 'repo not found',
|
|
||||||
}
|
|
||||||
return this._requestSvg({
|
return this._requestSvg({
|
||||||
schema,
|
schema,
|
||||||
url,
|
url,
|
||||||
|
|||||||
19
services/gitlab/gitlab-helper.js
Normal file
19
services/gitlab/gitlab-helper.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
const documentation = `
|
||||||
|
<p>
|
||||||
|
You may use your GitLab Project Id (e.g. 278964) or your Project Path (e.g.
|
||||||
|
<a href="https://gitlab.com/gitlab-org/gitlab" target="_blank" >gitlab-org/gitlab</a> ).
|
||||||
|
Note that only internet-accessible GitLab instances are supported, for example
|
||||||
|
<a href="https://jihulab.com" target="_blank" >https://jihulab.com</a>,
|
||||||
|
<a href="https://gitlab.gnome.org" target="_blank" >https://gitlab.gnome.org</a>, or
|
||||||
|
<a href="https://gitlab.com" target="_blank" >https://gitlab.com</a>.
|
||||||
|
</p>
|
||||||
|
`
|
||||||
|
|
||||||
|
function errorMessagesFor(notFoundMessage = 'project not found') {
|
||||||
|
return {
|
||||||
|
401: notFoundMessage,
|
||||||
|
404: notFoundMessage,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { documentation, errorMessagesFor }
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import Joi from 'joi'
|
import Joi from 'joi'
|
||||||
import { optionalUrl, nonNegativeInteger } from '../validators.js'
|
import { optionalUrl, nonNegativeInteger } from '../validators.js'
|
||||||
import { metric } from '../text-formatters.js'
|
import { metric } from '../text-formatters.js'
|
||||||
|
import { documentation, errorMessagesFor } from './gitlab-helper.js'
|
||||||
import GitLabBase from './gitlab-base.js'
|
import GitLabBase from './gitlab-base.js'
|
||||||
|
|
||||||
const schema = Joi.object({
|
const schema = Joi.object({
|
||||||
@@ -18,13 +19,6 @@ const queryParamSchema = Joi.object({
|
|||||||
gitlab_url: optionalUrl,
|
gitlab_url: optionalUrl,
|
||||||
}).required()
|
}).required()
|
||||||
|
|
||||||
const documentation = `
|
|
||||||
<p>
|
|
||||||
You may use your GitLab Project Id (e.g. 278964) or your Project Path (e.g. gitlab-org/gitlab ).
|
|
||||||
Note that only internet-accessible GitLab instances are supported, for example https://jihulab.com, https://gitlab.gnome.org, or https://gitlab.com/.
|
|
||||||
</p>
|
|
||||||
`
|
|
||||||
|
|
||||||
const labelDocumentation = `
|
const labelDocumentation = `
|
||||||
<p>
|
<p>
|
||||||
If you want to use multiple labels then please use commas (<code>,</code>) to separate them, e.g. <code>foo,bar</code>.
|
If you want to use multiple labels then please use commas (<code>,</code>) to separate them, e.g. <code>foo,bar</code>.
|
||||||
@@ -243,9 +237,7 @@ export default class GitlabIssues extends GitLabBase {
|
|||||||
project
|
project
|
||||||
)}/issues_statistics`,
|
)}/issues_statistics`,
|
||||||
options: labels ? { searchParams: { labels } } : undefined,
|
options: labels ? { searchParams: { labels } } : undefined,
|
||||||
errorMessages: {
|
errorMessages: errorMessagesFor('project not found'),
|
||||||
404: 'project not found',
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import Joi from 'joi'
|
import Joi from 'joi'
|
||||||
import { optionalUrl } from '../validators.js'
|
import { optionalUrl } from '../validators.js'
|
||||||
import { renderLicenseBadge } from '../licenses.js'
|
import { renderLicenseBadge } from '../licenses.js'
|
||||||
|
import { documentation, errorMessagesFor } from './gitlab-helper.js'
|
||||||
import GitLabBase from './gitlab-base.js'
|
import GitLabBase from './gitlab-base.js'
|
||||||
|
|
||||||
const schema = Joi.object({
|
const schema = Joi.object({
|
||||||
@@ -13,19 +14,6 @@ const queryParamSchema = Joi.object({
|
|||||||
gitlab_url: optionalUrl,
|
gitlab_url: optionalUrl,
|
||||||
}).required()
|
}).required()
|
||||||
|
|
||||||
const documentation = `
|
|
||||||
<p>
|
|
||||||
You may use your GitLab Project Id (e.g. 278964) or your Project Path (e.g. gitlab-org/gitlab )
|
|
||||||
</p>
|
|
||||||
`
|
|
||||||
|
|
||||||
const customDocumentation = `
|
|
||||||
<p>
|
|
||||||
Note that only internet-accessible GitLab instances are supported, for example https://jihulab.com, https://gitlab.gnome.org, or https://gitlab.com/.
|
|
||||||
You may use your GitLab Project Id (e.g. 13953) or your Project Path (e.g. gitlab-cn/gitlab ) in <a href="https://jihulab.com">https://jihulab.com</a>
|
|
||||||
</p>
|
|
||||||
`
|
|
||||||
|
|
||||||
export default class GitlabLicense extends GitLabBase {
|
export default class GitlabLicense extends GitLabBase {
|
||||||
static category = 'license'
|
static category = 'license'
|
||||||
|
|
||||||
@@ -59,7 +47,7 @@ export default class GitlabLicense extends GitLabBase {
|
|||||||
message: 'MIT License',
|
message: 'MIT License',
|
||||||
color: 'green',
|
color: 'green',
|
||||||
},
|
},
|
||||||
documentation: customDocumentation,
|
documentation,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -79,9 +67,7 @@ export default class GitlabLicense extends GitLabBase {
|
|||||||
schema,
|
schema,
|
||||||
url: `${baseUrl}/api/v4/projects/${encodeURIComponent(project)}`,
|
url: `${baseUrl}/api/v4/projects/${encodeURIComponent(project)}`,
|
||||||
options: { searchParams: { license: '1' } },
|
options: { searchParams: { license: '1' } },
|
||||||
errorMessages: {
|
errorMessages: errorMessagesFor('project not found'),
|
||||||
404: 'repo not found',
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ t.create('License for unknown repo')
|
|||||||
.get('/user1/gitlab-does-not-have-this-repo.json')
|
.get('/user1/gitlab-does-not-have-this-repo.json')
|
||||||
.expectBadge({
|
.expectBadge({
|
||||||
label: 'license',
|
label: 'license',
|
||||||
message: 'repo not found',
|
message: 'project not found',
|
||||||
color: 'red',
|
color: 'red',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import Joi from 'joi'
|
import Joi from 'joi'
|
||||||
import { optionalUrl, nonNegativeInteger } from '../validators.js'
|
import { optionalUrl, nonNegativeInteger } from '../validators.js'
|
||||||
import { metric } from '../text-formatters.js'
|
import { metric } from '../text-formatters.js'
|
||||||
|
import { documentation, errorMessagesFor } from './gitlab-helper.js'
|
||||||
import GitLabBase from './gitlab-base.js'
|
import GitLabBase from './gitlab-base.js'
|
||||||
|
|
||||||
// The total number of MR is in the `x-total` field in the headers.
|
// The total number of MR is in the `x-total` field in the headers.
|
||||||
@@ -15,20 +16,22 @@ const queryParamSchema = Joi.object({
|
|||||||
gitlab_url: optionalUrl,
|
gitlab_url: optionalUrl,
|
||||||
}).required()
|
}).required()
|
||||||
|
|
||||||
const documentation = `
|
const more = `
|
||||||
<p>
|
<p>
|
||||||
You may use your GitLab Project Id (e.g. 278964) or your Project Path (e.g. gitlab-org/gitlab ).
|
|
||||||
Note that only internet-accessible GitLab instances are supported, for example https://jihulab.com, https://gitlab.gnome.org, or https://gitlab.com/.
|
|
||||||
<a href="https://docs.gitlab.com/ee/user/gitlab_com/index.html#pagination-response-headers">GitLab's API </a> only reports up to 10k Merge Requests, so badges for projects that have more than 10k will not have an exact count.
|
<a href="https://docs.gitlab.com/ee/user/gitlab_com/index.html#pagination-response-headers">GitLab's API </a> only reports up to 10k Merge Requests, so badges for projects that have more than 10k will not have an exact count.
|
||||||
</p>
|
</p>
|
||||||
`
|
`
|
||||||
|
|
||||||
const labelDocumentation = `
|
const labelText = `
|
||||||
<p>
|
<p>
|
||||||
If you want to use multiple labels then please use commas (<code>,</code>) to separate them, e.g. <code>foo,bar</code>.
|
If you want to use multiple labels then please use commas (<code>,</code>) to separate them, e.g. <code>foo,bar</code>.
|
||||||
</p>
|
</p>
|
||||||
`
|
`
|
||||||
|
|
||||||
|
const defaultDocumentation = documentation + more
|
||||||
|
|
||||||
|
const labelDocumentation = documentation + labelText + more
|
||||||
|
|
||||||
export default class GitlabMergeRequests extends GitLabBase {
|
export default class GitlabMergeRequests extends GitLabBase {
|
||||||
static category = 'issue-tracking'
|
static category = 'issue-tracking'
|
||||||
|
|
||||||
@@ -51,7 +54,7 @@ export default class GitlabMergeRequests extends GitLabBase {
|
|||||||
message: '1.4k open',
|
message: '1.4k open',
|
||||||
color: 'blue',
|
color: 'blue',
|
||||||
},
|
},
|
||||||
documentation,
|
documentation: defaultDocumentation,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'GitLab merge requests',
|
title: 'GitLab merge requests',
|
||||||
@@ -65,7 +68,7 @@ export default class GitlabMergeRequests extends GitLabBase {
|
|||||||
message: '1.4k',
|
message: '1.4k',
|
||||||
color: 'blue',
|
color: 'blue',
|
||||||
},
|
},
|
||||||
documentation,
|
documentation: defaultDocumentation,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'GitLab merge requests by-label',
|
title: 'GitLab merge requests by-label',
|
||||||
@@ -82,7 +85,7 @@ export default class GitlabMergeRequests extends GitLabBase {
|
|||||||
message: '3 open',
|
message: '3 open',
|
||||||
color: 'blue',
|
color: 'blue',
|
||||||
},
|
},
|
||||||
documentation: documentation + labelDocumentation,
|
documentation: labelDocumentation,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'GitLab merge requests by-label',
|
title: 'GitLab merge requests by-label',
|
||||||
@@ -99,7 +102,7 @@ export default class GitlabMergeRequests extends GitLabBase {
|
|||||||
message: '3',
|
message: '3',
|
||||||
color: 'blue',
|
color: 'blue',
|
||||||
},
|
},
|
||||||
documentation: documentation + labelDocumentation,
|
documentation: labelDocumentation,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'GitLab closed merge requests',
|
title: 'GitLab closed merge requests',
|
||||||
@@ -113,7 +116,7 @@ export default class GitlabMergeRequests extends GitLabBase {
|
|||||||
message: 'more than 10k closed',
|
message: 'more than 10k closed',
|
||||||
color: 'blue',
|
color: 'blue',
|
||||||
},
|
},
|
||||||
documentation,
|
documentation: defaultDocumentation,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'GitLab closed merge requests',
|
title: 'GitLab closed merge requests',
|
||||||
@@ -127,7 +130,7 @@ export default class GitlabMergeRequests extends GitLabBase {
|
|||||||
message: 'more than 10k',
|
message: 'more than 10k',
|
||||||
color: 'blue',
|
color: 'blue',
|
||||||
},
|
},
|
||||||
documentation,
|
documentation: defaultDocumentation,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'GitLab closed merge requests by-label',
|
title: 'GitLab closed merge requests by-label',
|
||||||
@@ -144,7 +147,7 @@ export default class GitlabMergeRequests extends GitLabBase {
|
|||||||
message: '32 closed',
|
message: '32 closed',
|
||||||
color: 'blue',
|
color: 'blue',
|
||||||
},
|
},
|
||||||
documentation: documentation + labelDocumentation,
|
documentation: labelDocumentation,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'GitLab closed merge requests by-label',
|
title: 'GitLab closed merge requests by-label',
|
||||||
@@ -161,7 +164,7 @@ export default class GitlabMergeRequests extends GitLabBase {
|
|||||||
message: '32',
|
message: '32',
|
||||||
color: 'blue',
|
color: 'blue',
|
||||||
},
|
},
|
||||||
documentation: documentation + labelDocumentation,
|
documentation: labelDocumentation,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'GitLab all merge requests',
|
title: 'GitLab all merge requests',
|
||||||
@@ -175,7 +178,7 @@ export default class GitlabMergeRequests extends GitLabBase {
|
|||||||
message: 'more than 10k all',
|
message: 'more than 10k all',
|
||||||
color: 'blue',
|
color: 'blue',
|
||||||
},
|
},
|
||||||
documentation,
|
documentation: defaultDocumentation,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'GitLab all merge requests',
|
title: 'GitLab all merge requests',
|
||||||
@@ -189,7 +192,7 @@ export default class GitlabMergeRequests extends GitLabBase {
|
|||||||
message: 'more than 10k',
|
message: 'more than 10k',
|
||||||
color: 'blue',
|
color: 'blue',
|
||||||
},
|
},
|
||||||
documentation,
|
documentation: defaultDocumentation,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'GitLab all merge requests by-label',
|
title: 'GitLab all merge requests by-label',
|
||||||
@@ -206,7 +209,7 @@ export default class GitlabMergeRequests extends GitLabBase {
|
|||||||
message: '12',
|
message: '12',
|
||||||
color: 'blue',
|
color: 'blue',
|
||||||
},
|
},
|
||||||
documentation: documentation + labelDocumentation,
|
documentation: labelDocumentation,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'GitLab locked merge requests',
|
title: 'GitLab locked merge requests',
|
||||||
@@ -220,7 +223,7 @@ export default class GitlabMergeRequests extends GitLabBase {
|
|||||||
message: '0 locked',
|
message: '0 locked',
|
||||||
color: 'blue',
|
color: 'blue',
|
||||||
},
|
},
|
||||||
documentation,
|
documentation: defaultDocumentation,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'GitLab locked merge requests by-label',
|
title: 'GitLab locked merge requests by-label',
|
||||||
@@ -237,7 +240,7 @@ export default class GitlabMergeRequests extends GitLabBase {
|
|||||||
message: '0 locked',
|
message: '0 locked',
|
||||||
color: 'blue',
|
color: 'blue',
|
||||||
},
|
},
|
||||||
documentation: documentation + labelDocumentation,
|
documentation: labelDocumentation,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'GitLab merged merge requests',
|
title: 'GitLab merged merge requests',
|
||||||
@@ -251,7 +254,7 @@ export default class GitlabMergeRequests extends GitLabBase {
|
|||||||
message: 'more than 10k merged',
|
message: 'more than 10k merged',
|
||||||
color: 'blue',
|
color: 'blue',
|
||||||
},
|
},
|
||||||
documentation,
|
documentation: defaultDocumentation,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'GitLab merged merge requests by-label',
|
title: 'GitLab merged merge requests by-label',
|
||||||
@@ -268,7 +271,7 @@ export default class GitlabMergeRequests extends GitLabBase {
|
|||||||
message: '68 merged',
|
message: '68 merged',
|
||||||
color: 'blue',
|
color: 'blue',
|
||||||
},
|
},
|
||||||
documentation: documentation + labelDocumentation,
|
documentation: labelDocumentation,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -311,9 +314,7 @@ export default class GitlabMergeRequests extends GitLabBase {
|
|||||||
labels,
|
labels,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
errorMessages: {
|
errorMessages: errorMessagesFor('project not found'),
|
||||||
404: 'project not found',
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
return this.constructor._validate(res.headers, schema)
|
return this.constructor._validate(res.headers, schema)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import Joi from 'joi'
|
|||||||
import { isBuildStatus, renderBuildStatusBadge } from '../build-status.js'
|
import { isBuildStatus, renderBuildStatusBadge } from '../build-status.js'
|
||||||
import { optionalUrl } from '../validators.js'
|
import { optionalUrl } from '../validators.js'
|
||||||
import { BaseSvgScrapingService, NotFound, redirector } from '../index.js'
|
import { BaseSvgScrapingService, NotFound, redirector } from '../index.js'
|
||||||
|
import { documentation, errorMessagesFor } from './gitlab-helper.js'
|
||||||
|
|
||||||
const badgeSchema = Joi.object({
|
const badgeSchema = Joi.object({
|
||||||
message: Joi.alternatives()
|
message: Joi.alternatives()
|
||||||
@@ -14,7 +15,7 @@ const queryParamSchema = Joi.object({
|
|||||||
branch: Joi.string(),
|
branch: Joi.string(),
|
||||||
}).required()
|
}).required()
|
||||||
|
|
||||||
const documentation = `
|
const moreDocs = `
|
||||||
<p>
|
<p>
|
||||||
Important: You must use the Project Path, not the Project Id. Additionally, if your project is publicly visible, but the badge is like this:
|
Important: You must use the Project Path, not the Project Id. Additionally, if your project is publicly visible, but the badge is like this:
|
||||||
<img src="https://img.shields.io/badge/build-not found-red" alt="build not found"/>
|
<img src="https://img.shields.io/badge/build-not found-red" alt="build not found"/>
|
||||||
@@ -51,14 +52,14 @@ class GitlabPipelineStatus extends BaseSvgScrapingService {
|
|||||||
namedParams: { project: 'gitlab-org/gitlab' },
|
namedParams: { project: 'gitlab-org/gitlab' },
|
||||||
queryParams: { branch: 'master' },
|
queryParams: { branch: 'master' },
|
||||||
staticPreview: this.render({ status: 'passed' }),
|
staticPreview: this.render({ status: 'passed' }),
|
||||||
documentation,
|
documentation: documentation + moreDocs,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Gitlab pipeline status (self-managed)',
|
title: 'Gitlab pipeline status (self-managed)',
|
||||||
namedParams: { project: 'GNOME/pango' },
|
namedParams: { project: 'GNOME/pango' },
|
||||||
queryParams: { gitlab_url: 'https://gitlab.gnome.org', branch: 'master' },
|
queryParams: { gitlab_url: 'https://gitlab.gnome.org', branch: 'master' },
|
||||||
staticPreview: this.render({ status: 'passed' }),
|
staticPreview: this.render({ status: 'passed' }),
|
||||||
documentation,
|
documentation: documentation + moreDocs,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -72,10 +73,7 @@ class GitlabPipelineStatus extends BaseSvgScrapingService {
|
|||||||
url: `${baseUrl}/${decodeURIComponent(
|
url: `${baseUrl}/${decodeURIComponent(
|
||||||
project
|
project
|
||||||
)}/badges/${branch}/pipeline.svg`,
|
)}/badges/${branch}/pipeline.svg`,
|
||||||
errorMessages: {
|
errorMessages: errorMessagesFor('project not found'),
|
||||||
401: 'repo not found',
|
|
||||||
404: 'repo not found',
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import Joi from 'joi'
|
|||||||
import { optionalUrl } from '../validators.js'
|
import { optionalUrl } from '../validators.js'
|
||||||
import { latest, renderVersionBadge } from '../version.js'
|
import { latest, renderVersionBadge } from '../version.js'
|
||||||
import { NotFound } from '../index.js'
|
import { NotFound } from '../index.js'
|
||||||
|
import { documentation, errorMessagesFor } from './gitlab-helper.js'
|
||||||
import GitLabBase from './gitlab-base.js'
|
import GitLabBase from './gitlab-base.js'
|
||||||
|
|
||||||
const schema = Joi.array().items(
|
const schema = Joi.array().items(
|
||||||
@@ -21,11 +22,6 @@ const queryParamSchema = Joi.object({
|
|||||||
.default('created_at'),
|
.default('created_at'),
|
||||||
}).required()
|
}).required()
|
||||||
|
|
||||||
const documentation = `
|
|
||||||
<p>
|
|
||||||
You may use your GitLab Project Id (e.g. 25813592) or your Project Path (e.g. megabyte-labs/dockerfile/ci-pipeline/ansible-lint)
|
|
||||||
</p>
|
|
||||||
`
|
|
||||||
const commonProps = {
|
const commonProps = {
|
||||||
namedParams: {
|
namedParams: {
|
||||||
project: 'shields-ops-group/tag-test',
|
project: 'shields-ops-group/tag-test',
|
||||||
@@ -102,9 +98,7 @@ export default class GitLabRelease extends GitLabBase {
|
|||||||
return this.fetchPaginatedArrayData({
|
return this.fetchPaginatedArrayData({
|
||||||
schema,
|
schema,
|
||||||
url: `${baseUrl}/api/v4/projects/${encodeURIComponent(project)}/releases`,
|
url: `${baseUrl}/api/v4/projects/${encodeURIComponent(project)}/releases`,
|
||||||
errorMessages: {
|
errorMessages: errorMessagesFor('project not found'),
|
||||||
404: 'project not found',
|
|
||||||
},
|
|
||||||
options: {
|
options: {
|
||||||
searchParams: { order_by: orderBy },
|
searchParams: { order_by: orderBy },
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { optionalUrl } from '../validators.js'
|
|||||||
import { latest } from '../version.js'
|
import { latest } from '../version.js'
|
||||||
import { addv } from '../text-formatters.js'
|
import { addv } from '../text-formatters.js'
|
||||||
import { NotFound } from '../index.js'
|
import { NotFound } from '../index.js'
|
||||||
|
import { documentation, errorMessagesFor } from './gitlab-helper.js'
|
||||||
import GitLabBase from './gitlab-base.js'
|
import GitLabBase from './gitlab-base.js'
|
||||||
|
|
||||||
const schema = Joi.array().items(
|
const schema = Joi.array().items(
|
||||||
@@ -18,11 +19,6 @@ const queryParamSchema = Joi.object({
|
|||||||
sort: Joi.string().valid('date', 'semver').default('date'),
|
sort: Joi.string().valid('date', 'semver').default('date'),
|
||||||
}).required()
|
}).required()
|
||||||
|
|
||||||
const documentation = `
|
|
||||||
<p>
|
|
||||||
You may use your GitLab Project Id (e.g. 25813592) or your Project Path (e.g. megabyte-labs/dockerfile/ci-pipeline/ansible-lint)
|
|
||||||
</p>
|
|
||||||
`
|
|
||||||
const commonProps = {
|
const commonProps = {
|
||||||
namedParams: {
|
namedParams: {
|
||||||
project: 'shields-ops-group/tag-test',
|
project: 'shields-ops-group/tag-test',
|
||||||
@@ -96,9 +92,7 @@ export default class GitlabTag extends GitLabBase {
|
|||||||
project
|
project
|
||||||
)}/repository/tags`,
|
)}/repository/tags`,
|
||||||
options: { searchParams: { order_by: 'updated' } },
|
options: { searchParams: { order_by: 'updated' } },
|
||||||
errorMessages: {
|
errorMessages: errorMessagesFor('project not found'),
|
||||||
404: 'repo not found',
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ t.create('Tag (custom instance)')
|
|||||||
|
|
||||||
t.create('Tag (repo not found)')
|
t.create('Tag (repo not found)')
|
||||||
.get('/fdroid/nonexistant.json')
|
.get('/fdroid/nonexistant.json')
|
||||||
.expectBadge({ label: 'tag', message: 'repo not found' })
|
.expectBadge({ label: 'tag', message: 'project not found' })
|
||||||
|
|
||||||
t.create('Tag (no tags)')
|
t.create('Tag (no tags)')
|
||||||
.get('/fdroid/fdroiddata.json')
|
.get('/fdroid/fdroiddata.json')
|
||||||
|
|||||||
Reference in New Issue
Block a user