Skip to content

Commit

Permalink
Add tag-prefix config option
Browse files Browse the repository at this point in the history
  • Loading branch information
mxj4 committed Dec 28, 2021
1 parent 4ace379 commit b622ac1
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
1 change: 1 addition & 0 deletions lib/default-config.js
Expand Up @@ -3,6 +3,7 @@ const { SORT_BY, SORT_DIRECTIONS } = require('./sort-pull-requests')
const DEFAULT_CONFIG = Object.freeze({
'name-template': '',
'tag-template': '',
'tag-prefix': '',
'change-template': `* $TITLE (#$NUMBER) @$AUTHOR`,
'change-title-escapes': '',
'no-changes-template': `* No changes`,
Expand Down
14 changes: 9 additions & 5 deletions lib/releases.js
Expand Up @@ -28,10 +28,13 @@ module.exports.findReleases = async ({ ref, context, config }) => {

log({ context, message: `Found ${releases.length} releases` })

const { 'filter-by-commitish': filterByCommitish } = config
const filteredReleases = filterByCommitish
? releases.filter((r) => ref.match(`/${r.target_commitish}$`))
: releases
const {
'filter-by-commitish': filterByCommitish,
'tag-prefix': tagPrefix
} = config
const filteredReleases = releases
.filter((r) => filterByCommitish ? ref.match(`/${r.target_commitish}$`) : r)
.filter((r) => (tagPrefix && tagPrefix.length > 0) ? r.tag_name.startsWith(tagPrefix) : r)
const sortedPublishedReleases = sortReleases(
filteredReleases.filter((r) => !r.draft)
)
Expand Down Expand Up @@ -294,7 +297,8 @@ module.exports.generateReleaseInfo = ({
}

if (tag === undefined) {
tag = versionInfo ? template(config['tag-template'] || '', versionInfo) : ''
const partialTag = versionInfo ? template(config['tag-template'] || '', versionInfo) : ''
tag = config['tag-prefix'] ? `${config['tag-prefix']}${partialTag}` : partialTag
}

if (name === undefined) {
Expand Down
4 changes: 4 additions & 0 deletions lib/schema.js
Expand Up @@ -38,6 +38,10 @@ const schema = (context) => {
.allow('')
.default(DEFAULT_CONFIG['tag-template']),

'tag-prefix': Joi.string()
.allow('')
.default(DEFAULT_CONFIG['tag-prefix']),

'exclude-labels': Joi.array()
.items(Joi.string())
.default(DEFAULT_CONFIG['exclude-labels']),
Expand Down
12 changes: 12 additions & 0 deletions schema.json
Expand Up @@ -59,6 +59,18 @@
}
]
},
"tag-prefix": {
"anyOf": [
{
"type": "string",
"enum": [""]
},
{
"default": "",
"type": "string"
}
]
},
"exclude-labels": {
"default": [],
"type": "array",
Expand Down

0 comments on commit b622ac1

Please sign in to comment.