- introduce new MERGE_SHA placeholder support into template for PRs (and commit SHA for commit mode)
- FIX https://github.com/mikepenz/release-changelog-builder-action/issues/552
This commit is contained in:
@@ -261,6 +261,7 @@ Table of supported placeholders allowed to be used in the `pr_template` configur
|
|||||||
| `${{TITLE}}` | Specified title of the merged pull request |
|
| `${{TITLE}}` | Specified title of the merged pull request |
|
||||||
| `${{URL}}` | Url linking to the pull request on GitHub |
|
| `${{URL}}` | Url linking to the pull request on GitHub |
|
||||||
| `${{MERGED_AT}}` | The ISO time, the pull request was merged at |
|
| `${{MERGED_AT}}` | The ISO time, the pull request was merged at |
|
||||||
|
| `${{MERGE_SHA}}` | The commit SHA, the pull request was merged with |
|
||||||
| `${{AUTHOR}}` | Author creating and opening the pull request |
|
| `${{AUTHOR}}` | Author creating and opening the pull request |
|
||||||
| `${{LABELS}}` | The labels associated with this pull request, joined by `,` |
|
| `${{LABELS}}` | The labels associated with this pull request, joined by `,` |
|
||||||
| `${{MILESTONE}}` | Milestone this PR was part of, as assigned on GitHub |
|
| `${{MILESTONE}}` | Milestone this PR was part of, as assigned on GitHub |
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ pullRequestsWithLabels.push(
|
|||||||
htmlURL: '',
|
htmlURL: '',
|
||||||
baseBranch: '',
|
baseBranch: '',
|
||||||
mergedAt: moment(),
|
mergedAt: moment(),
|
||||||
mergeCommitSha: 'sha1',
|
mergeCommitSha: 'sha1-1',
|
||||||
author: 'Mike',
|
author: 'Mike',
|
||||||
repoName: 'test-repo',
|
repoName: 'test-repo',
|
||||||
labels: new Set<string>().add('feature'),
|
labels: new Set<string>().add('feature'),
|
||||||
@@ -216,7 +216,7 @@ pullRequestsWithLabels.push(
|
|||||||
htmlURL: '',
|
htmlURL: '',
|
||||||
baseBranch: '',
|
baseBranch: '',
|
||||||
mergedAt: moment(),
|
mergedAt: moment(),
|
||||||
mergeCommitSha: 'sha1',
|
mergeCommitSha: 'sha1-2',
|
||||||
author: 'Mike',
|
author: 'Mike',
|
||||||
repoName: 'test-repo',
|
repoName: 'test-repo',
|
||||||
labels: new Set<string>().add('issue').add('fix'),
|
labels: new Set<string>().add('issue').add('fix'),
|
||||||
@@ -231,7 +231,7 @@ pullRequestsWithLabels.push(
|
|||||||
htmlURL: '',
|
htmlURL: '',
|
||||||
baseBranch: '',
|
baseBranch: '',
|
||||||
mergedAt: moment().add(1, 'days'),
|
mergedAt: moment().add(1, 'days'),
|
||||||
mergeCommitSha: 'sha1',
|
mergeCommitSha: 'sha1-3',
|
||||||
author: 'Mike',
|
author: 'Mike',
|
||||||
repoName: 'test-repo',
|
repoName: 'test-repo',
|
||||||
labels: new Set<string>().add('issue').add('feature').add('fix'),
|
labels: new Set<string>().add('issue').add('feature').add('fix'),
|
||||||
@@ -246,7 +246,7 @@ pullRequestsWithLabels.push(
|
|||||||
htmlURL: '',
|
htmlURL: '',
|
||||||
baseBranch: '',
|
baseBranch: '',
|
||||||
mergedAt: moment(),
|
mergedAt: moment(),
|
||||||
mergeCommitSha: 'sha1',
|
mergeCommitSha: 'sha1-4',
|
||||||
author: 'Mike',
|
author: 'Mike',
|
||||||
repoName: 'test-repo',
|
repoName: 'test-repo',
|
||||||
labels: new Set<string>().add(''),
|
labels: new Set<string>().add(''),
|
||||||
@@ -337,4 +337,24 @@ it('Deduplicate duplicated PRs DESC', async () => {
|
|||||||
expect(resultChangelog).toStrictEqual(
|
expect(resultChangelog).toStrictEqual(
|
||||||
`## 🚀 Features\n\n- [ABC-1234] - this is a PR 1 title message\n - PR: #1\n\n## 🐛 Fixes\n\n- [ABC-4321] - this is a PR 2 title message\n - PR: #2\n\n`
|
`## 🚀 Features\n\n- [ABC-1234] - this is a PR 1 title message\n - PR: #1\n\n## 🐛 Fixes\n\n- [ABC-4321] - this is a PR 2 title message\n - PR: #2\n\n`
|
||||||
)
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Commit SHA-1 in commitMode', async () => {
|
||||||
|
const customConfig = Object.assign({}, DefaultConfiguration)
|
||||||
|
customConfig.sort = "DESC"
|
||||||
|
customConfig.pr_template = "${{MERGE_SHA}}"
|
||||||
|
|
||||||
|
const resultChangelog = buildChangelog(pullRequestsWithLabels, {
|
||||||
|
owner: 'mikepenz',
|
||||||
|
repo: 'test-repo',
|
||||||
|
fromTag: '1.0.0',
|
||||||
|
toTag: '2.0.0',
|
||||||
|
failOnError: false,
|
||||||
|
commitMode: true,
|
||||||
|
configuration: customConfig
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(resultChangelog).toStrictEqual(
|
||||||
|
`## 🚀 Features\n\nsha1-3\nsha1-1\n\n## 🐛 Fixes\n\nsha1-3\nsha1-2\n\n`
|
||||||
|
)
|
||||||
})
|
})
|
||||||
+2
-1
@@ -702,7 +702,7 @@ class ReleaseNotes {
|
|||||||
htmlURL: '',
|
htmlURL: '',
|
||||||
baseBranch: '',
|
baseBranch: '',
|
||||||
mergedAt: commit.date,
|
mergedAt: commit.date,
|
||||||
mergeCommitSha: '',
|
mergeCommitSha: commit.sha,
|
||||||
author: commit.author || '',
|
author: commit.author || '',
|
||||||
repoName: '',
|
repoName: '',
|
||||||
labels: new Set(),
|
labels: new Set(),
|
||||||
@@ -1288,6 +1288,7 @@ function fillTemplate(pr, template) {
|
|||||||
transformed = transformed.replace(/\${{TITLE}}/g, pr.title);
|
transformed = transformed.replace(/\${{TITLE}}/g, pr.title);
|
||||||
transformed = transformed.replace(/\${{URL}}/g, pr.htmlURL);
|
transformed = transformed.replace(/\${{URL}}/g, pr.htmlURL);
|
||||||
transformed = transformed.replace(/\${{MERGED_AT}}/g, pr.mergedAt.toISOString());
|
transformed = transformed.replace(/\${{MERGED_AT}}/g, pr.mergedAt.toISOString());
|
||||||
|
transformed = transformed.replace(/\${{MERGE_SHA}}/g, pr.mergeCommitSha);
|
||||||
transformed = transformed.replace(/\${{AUTHOR}}/g, pr.author);
|
transformed = transformed.replace(/\${{AUTHOR}}/g, pr.author);
|
||||||
transformed = transformed.replace(/\${{LABELS}}/g, ((_a = [...pr.labels]) === null || _a === void 0 ? void 0 : _a.join(', ')) || '');
|
transformed = transformed.replace(/\${{LABELS}}/g, ((_a = [...pr.labels]) === null || _a === void 0 ? void 0 : _a.join(', ')) || '');
|
||||||
transformed = transformed.replace(/\${{MILESTONE}}/g, pr.milestone || '');
|
transformed = transformed.replace(/\${{MILESTONE}}/g, pr.milestone || '');
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -178,7 +178,7 @@ export class ReleaseNotes {
|
|||||||
htmlURL: '',
|
htmlURL: '',
|
||||||
baseBranch: '',
|
baseBranch: '',
|
||||||
mergedAt: commit.date,
|
mergedAt: commit.date,
|
||||||
mergeCommitSha: '',
|
mergeCommitSha: commit.sha,
|
||||||
author: commit.author || '',
|
author: commit.author || '',
|
||||||
repoName: '',
|
repoName: '',
|
||||||
labels: new Set(),
|
labels: new Set(),
|
||||||
|
|||||||
@@ -246,6 +246,7 @@ function fillTemplate(pr: PullRequestInfo, template: string): string {
|
|||||||
/\${{MERGED_AT}}/g,
|
/\${{MERGED_AT}}/g,
|
||||||
pr.mergedAt.toISOString()
|
pr.mergedAt.toISOString()
|
||||||
)
|
)
|
||||||
|
transformed = transformed.replace(/\${{MERGE_SHA}}/g, pr.mergeCommitSha)
|
||||||
transformed = transformed.replace(/\${{AUTHOR}}/g, pr.author)
|
transformed = transformed.replace(/\${{AUTHOR}}/g, pr.author)
|
||||||
transformed = transformed.replace(
|
transformed = transformed.replace(
|
||||||
/\${{LABELS}}/g,
|
/\${{LABELS}}/g,
|
||||||
|
|||||||
Reference in New Issue
Block a user