Merge pull request #553 from mikepenz/feature/552
Add MERGE_SHA placeholder support into template
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 |
|
||||
| `${{URL}}` | Url linking to the pull request on GitHub |
|
||||
| `${{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 |
|
||||
| `${{LABELS}}` | The labels associated with this pull request, joined by `,` |
|
||||
| `${{MILESTONE}}` | Milestone this PR was part of, as assigned on GitHub |
|
||||
|
||||
@@ -201,7 +201,7 @@ pullRequestsWithLabels.push(
|
||||
htmlURL: '',
|
||||
baseBranch: '',
|
||||
mergedAt: moment(),
|
||||
mergeCommitSha: 'sha1',
|
||||
mergeCommitSha: 'sha1-1',
|
||||
author: 'Mike',
|
||||
repoName: 'test-repo',
|
||||
labels: new Set<string>().add('feature'),
|
||||
@@ -216,7 +216,7 @@ pullRequestsWithLabels.push(
|
||||
htmlURL: '',
|
||||
baseBranch: '',
|
||||
mergedAt: moment(),
|
||||
mergeCommitSha: 'sha1',
|
||||
mergeCommitSha: 'sha1-2',
|
||||
author: 'Mike',
|
||||
repoName: 'test-repo',
|
||||
labels: new Set<string>().add('issue').add('fix'),
|
||||
@@ -231,7 +231,7 @@ pullRequestsWithLabels.push(
|
||||
htmlURL: '',
|
||||
baseBranch: '',
|
||||
mergedAt: moment().add(1, 'days'),
|
||||
mergeCommitSha: 'sha1',
|
||||
mergeCommitSha: 'sha1-3',
|
||||
author: 'Mike',
|
||||
repoName: 'test-repo',
|
||||
labels: new Set<string>().add('issue').add('feature').add('fix'),
|
||||
@@ -246,7 +246,7 @@ pullRequestsWithLabels.push(
|
||||
htmlURL: '',
|
||||
baseBranch: '',
|
||||
mergedAt: moment(),
|
||||
mergeCommitSha: 'sha1',
|
||||
mergeCommitSha: 'sha1-4',
|
||||
author: 'Mike',
|
||||
repoName: 'test-repo',
|
||||
labels: new Set<string>().add(''),
|
||||
@@ -338,3 +338,23 @@ it('Deduplicate duplicated PRs DESC', async () => {
|
||||
`## 🚀 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: '',
|
||||
baseBranch: '',
|
||||
mergedAt: commit.date,
|
||||
mergeCommitSha: '',
|
||||
mergeCommitSha: commit.sha,
|
||||
author: commit.author || '',
|
||||
repoName: '',
|
||||
labels: new Set(),
|
||||
@@ -1288,6 +1288,7 @@ function fillTemplate(pr, template) {
|
||||
transformed = transformed.replace(/\${{TITLE}}/g, pr.title);
|
||||
transformed = transformed.replace(/\${{URL}}/g, pr.htmlURL);
|
||||
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(/\${{LABELS}}/g, ((_a = [...pr.labels]) === null || _a === void 0 ? void 0 : _a.join(', ')) || '');
|
||||
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: '',
|
||||
baseBranch: '',
|
||||
mergedAt: commit.date,
|
||||
mergeCommitSha: '',
|
||||
mergeCommitSha: commit.sha,
|
||||
author: commit.author || '',
|
||||
repoName: '',
|
||||
labels: new Set(),
|
||||
|
||||
@@ -246,6 +246,7 @@ function fillTemplate(pr: PullRequestInfo, template: string): string {
|
||||
/\${{MERGED_AT}}/g,
|
||||
pr.mergedAt.toISOString()
|
||||
)
|
||||
transformed = transformed.replace(/\${{MERGE_SHA}}/g, pr.mergeCommitSha)
|
||||
transformed = transformed.replace(/\${{AUTHOR}}/g, pr.author)
|
||||
transformed = transformed.replace(
|
||||
/\${{LABELS}}/g,
|
||||
|
||||
Reference in New Issue
Block a user