* feat: Add total commits to GithubCommitActivity As part of a new feature proposed at issue #6070 added the requested feature. I also used the conversation at pull request #6081 as a basis for those changes. This change adds a new interval to the github/commit-activity shield 'total' (t for short). The interval shows the total commits of the repo since its creation. * Fix format with prettier * Label for 'total' interval is now commits Label change for the 'total' interval from 'commit activity' to 'commits' --------- Co-authored-by: jNullj <jNullj@users.noreply.github.com> Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
55 lines
1.3 KiB
JavaScript
55 lines
1.3 KiB
JavaScript
import Joi from 'joi'
|
|
import {
|
|
isMetricOverTimePeriod,
|
|
isZeroOverTimePeriod,
|
|
isMetric,
|
|
} from '../test-validators.js'
|
|
import { createServiceTester } from '../tester.js'
|
|
export const t = await createServiceTester()
|
|
|
|
const isCommitActivity = Joi.alternatives().try(
|
|
isMetricOverTimePeriod,
|
|
isZeroOverTimePeriod
|
|
)
|
|
|
|
t.create('commit acticity (total)').get('/t/badges/shields.json').expectBadge({
|
|
label: 'commits',
|
|
message: isMetric,
|
|
})
|
|
|
|
t.create('commit activity (1 year)').get('/y/eslint/eslint.json').expectBadge({
|
|
label: 'commit activity',
|
|
message: isMetricOverTimePeriod,
|
|
})
|
|
|
|
t.create('commit activity (1 month)').get('/m/eslint/eslint.json').expectBadge({
|
|
label: 'commit activity',
|
|
message: isMetricOverTimePeriod,
|
|
})
|
|
|
|
t.create('commit activity (4 weeks)')
|
|
.get('/4w/eslint/eslint.json')
|
|
.expectBadge({
|
|
label: 'commit activity',
|
|
message: isMetricOverTimePeriod,
|
|
})
|
|
|
|
t.create('commit activity (1 week)').get('/w/eslint/eslint.json').expectBadge({
|
|
label: 'commit activity',
|
|
message: isCommitActivity,
|
|
})
|
|
|
|
t.create('commit activity (custom branch)')
|
|
.get('/y/badges/squint/main.json')
|
|
.expectBadge({
|
|
label: 'commit activity',
|
|
message: isCommitActivity,
|
|
})
|
|
|
|
t.create('commit activity (repo not found)')
|
|
.get('/w/badges/helmets.json')
|
|
.expectBadge({
|
|
label: 'commit activity',
|
|
message: 'repo not found',
|
|
})
|