Add base branches as configuration
This commit is contained in:
@@ -190,7 +190,8 @@ This configuration is a `.json` file in the following format.
|
||||
],
|
||||
"tag_resolver": {
|
||||
"method": "semver"
|
||||
}
|
||||
},
|
||||
"base_branches": []
|
||||
}
|
||||
```
|
||||
|
||||
@@ -301,6 +302,7 @@ Table of descriptions for the `configuration.json` options to configure the resu
|
||||
| exclude_merge_branches | An array of branches to be ignored from processing as merge commits |
|
||||
| tag_resolver | Section to provide configuration for the tag resolving logic. Used if no `fromTag` is provided |
|
||||
| tag_resolver.method | Defines the method to use. Current options are: `semver`, `sort`. Default: `semver` |
|
||||
| base_branches | The target branches for the merged PR, ingnores PRs with different target branch. If empty gets all base branches. Default: all base branches
|
||||
|
||||
## Contribute 🧬
|
||||
|
||||
|
||||
@@ -159,3 +159,43 @@ it('Should match ordered DESC', async () => {
|
||||
`## 🚀 Features\n\n28\n26\n25\n24\n22\n\n## 🐛 Fixes\n\n23\n\n`
|
||||
)
|
||||
})
|
||||
|
||||
it('Should ignore PRs not merged into develop branch', async () => {
|
||||
const configuration = resolveConfiguration(
|
||||
'',
|
||||
'configs_test/configuration_base_branches_develop.json'
|
||||
)
|
||||
const releaseNotes = new ReleaseNotes(octokit, {
|
||||
owner: 'mikepenz',
|
||||
repo: 'release-changelog-builder-action',
|
||||
fromTag: 'v1.3.1',
|
||||
toTag: 'v1.4.0',
|
||||
failOnError: false,
|
||||
commitMode: false,
|
||||
configuration: configuration
|
||||
})
|
||||
|
||||
const changeLog = await releaseNotes.pull()
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(`\n\n150\n\n`)
|
||||
})
|
||||
|
||||
it('Should ignore PRs not merged into main branch', async () => {
|
||||
const configuration = resolveConfiguration(
|
||||
'',
|
||||
'configs_test/configuration_base_branches_main.json'
|
||||
)
|
||||
const releaseNotes = new ReleaseNotes(octokit, {
|
||||
owner: 'mikepenz',
|
||||
repo: 'release-changelog-builder-action',
|
||||
fromTag: 'v1.3.1',
|
||||
toTag: 'v1.4.0',
|
||||
failOnError: false,
|
||||
commitMode: false,
|
||||
configuration: configuration
|
||||
})
|
||||
|
||||
const changeLog = await releaseNotes.pull()
|
||||
console.log(changeLog)
|
||||
expect(changeLog).toStrictEqual(`\n\n153\n\n`)
|
||||
})
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"categories": [
|
||||
{
|
||||
"title": "",
|
||||
"labels": ["dev", "Bump"]
|
||||
}
|
||||
],
|
||||
"ignore_labels": [],
|
||||
"sort": "DESC",
|
||||
"pr_template": "${{NUMBER}}",
|
||||
"label_extractor": [
|
||||
{
|
||||
"pattern": ".*(dev|Bump).*",
|
||||
"target": "$1",
|
||||
"on_property": "title"
|
||||
}
|
||||
],
|
||||
"base_branches": ["develop"]
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"categories": [
|
||||
{
|
||||
"title": "",
|
||||
"labels": ["dev", "Bump"]
|
||||
}
|
||||
],
|
||||
"ignore_labels": [],
|
||||
"sort": "DESC",
|
||||
"pr_template": "${{NUMBER}}",
|
||||
"label_extractor": [
|
||||
{
|
||||
"pattern": ".*(dev|Bump).*",
|
||||
"target": "$1",
|
||||
"on_property": "title"
|
||||
}
|
||||
],
|
||||
"base_branches": ["main"]
|
||||
}
|
||||
@@ -12,6 +12,7 @@ export interface Configuration {
|
||||
label_extractor: Extractor[]
|
||||
transformers: Transformer[]
|
||||
tag_resolver: TagResolver
|
||||
base_branches: string[]
|
||||
}
|
||||
|
||||
export interface Category {
|
||||
@@ -61,5 +62,6 @@ export const DefaultConfiguration: Configuration = {
|
||||
tag_resolver: {
|
||||
// defines the logic on how to resolve the previous tag, only relevant if `fromTag` is not specified
|
||||
method: 'semver' // defines which method to use, by default it will use `semver` (dropping all non matching tags). Alternative `sort` is also available.
|
||||
}
|
||||
},
|
||||
base_branches: [] // target branches for the merged PR ignoring PRs with different target branch, by default it will get all PRs
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ export interface PullRequestInfo {
|
||||
number: number
|
||||
title: string
|
||||
htmlURL: string
|
||||
baseBranch: string
|
||||
mergedAt: moment.Moment
|
||||
mergeCommitSha: string
|
||||
author: string
|
||||
@@ -37,6 +38,7 @@ export class PullRequests {
|
||||
number: pr.data.number,
|
||||
title: pr.data.title,
|
||||
htmlURL: pr.data.html_url,
|
||||
baseBranch: pr.data.base.ref,
|
||||
mergedAt: moment(pr.data.merged_at),
|
||||
mergeCommitSha: pr.data.merge_commit_sha || '',
|
||||
author: pr.data.user?.login || '',
|
||||
@@ -90,6 +92,7 @@ export class PullRequests {
|
||||
number: pr.number,
|
||||
title: pr.title,
|
||||
htmlURL: pr.html_url,
|
||||
baseBranch: pr.base.ref,
|
||||
mergedAt: moment(pr.merged_at),
|
||||
mergeCommitSha: pr.merge_commit_sha || '',
|
||||
author: pr.user?.login || '',
|
||||
|
||||
@@ -130,7 +130,11 @@ export class ReleaseNotes {
|
||||
|
||||
// return only the pull requests associated with this release
|
||||
return pullRequests.filter(pr => {
|
||||
const baseBranches = configuration.base_branches || DefaultConfiguration.base_branches
|
||||
const allBaseBranchesAllowed = baseBranches.length === 0
|
||||
|
||||
return releaseCommitHashes.includes(pr.mergeCommitSha)
|
||||
&& (allBaseBranchesAllowed || baseBranches.includes(pr.baseBranch))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -157,6 +161,7 @@ export class ReleaseNotes {
|
||||
number: 0,
|
||||
title: commit.summary,
|
||||
htmlURL: '',
|
||||
baseBranch: '',
|
||||
mergedAt: commit.date,
|
||||
mergeCommitSha: '',
|
||||
author: commit.author || '',
|
||||
|
||||
Reference in New Issue
Block a user