- drop support for tag SHA as in most cases this information is not available at the moment
- introduce new testcase to verify `DAYS_SINCE` calculation - fix wrong log messages using the `TagInfo` object instead the name - add additional log messages
This commit is contained in:
@@ -314,7 +314,7 @@ it('Verify custom categorisation of open PRs', async () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Verify reviewers who approved are fetched', async () => {
|
it('Verify reviewers who approved are fetched and also release information', async () => {
|
||||||
const configuration = resolveConfiguration(
|
const configuration = resolveConfiguration(
|
||||||
'',
|
'',
|
||||||
'configs_test/configuration_approvers.json'
|
'configs_test/configuration_approvers.json'
|
||||||
@@ -331,7 +331,7 @@ it('Verify reviewers who approved are fetched', async () => {
|
|||||||
false, // failOnError
|
false, // failOnError
|
||||||
false, // ignorePrePrelease
|
false, // ignorePrePrelease
|
||||||
true, // enable to fetch reviewers
|
true, // enable to fetch reviewers
|
||||||
false, // enable to fetch tag release information
|
true, // enable to fetch tag release information
|
||||||
false, // commitMode
|
false, // commitMode
|
||||||
configuration // configuration
|
configuration // configuration
|
||||||
)
|
)
|
||||||
@@ -339,6 +339,65 @@ it('Verify reviewers who approved are fetched', async () => {
|
|||||||
const changeLog = await releaseNotesBuilder.build()
|
const changeLog = await releaseNotesBuilder.build()
|
||||||
console.log(changeLog)
|
console.log(changeLog)
|
||||||
expect(changeLog).toStrictEqual(
|
expect(changeLog).toStrictEqual(
|
||||||
`## 🚀 Features\n\n- A feature to be going to v2 (nr3) -- (#3) [merged] --- \n- New feature to keep open (nr5) -- (#7) [open] --- gabrielpopa\n\n`
|
`## 🚀 Features\n\n- A feature to be going to v2 (nr3) -- (#3) [merged] --- \n- New feature to keep open (nr5) -- (#7) [open] --- gabrielpopa\n\n\n\n0`
|
||||||
)
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
it('Fetch release information', async () => {
|
||||||
|
const configuration = resolveConfiguration(
|
||||||
|
'',
|
||||||
|
'configs_test/configuration_approvers.json'
|
||||||
|
)
|
||||||
|
configuration.template = "${{FROM_TAG}}-${{FROM_TAG_DATE}}\n${{TO_TAG}}-${{TO_TAG_DATE}}\n${{DAYS_SINCE}}"
|
||||||
|
const releaseNotesBuilder = new ReleaseNotesBuilder(
|
||||||
|
null, // baseUrl
|
||||||
|
null, // token
|
||||||
|
'.', // repoPath
|
||||||
|
'mikepenz', // user
|
||||||
|
'release-changelog-builder-action-playground', // repo
|
||||||
|
'2.0.0', // fromTag
|
||||||
|
'3.0.0-a01', // toTag
|
||||||
|
true, // includeOpen
|
||||||
|
false, // failOnError
|
||||||
|
false, // ignorePrePrelease
|
||||||
|
false, // enable to fetch reviewers
|
||||||
|
true, // enable to fetch tag release information
|
||||||
|
false, // commitMode
|
||||||
|
configuration // configuration
|
||||||
|
)
|
||||||
|
|
||||||
|
const changeLog = await releaseNotesBuilder.build()
|
||||||
|
console.log(changeLog)
|
||||||
|
expect(changeLog).toStrictEqual(
|
||||||
|
`2.0.0-2022-04-08T07:52:40.000Z\n3.0.0-a01-2022-07-26T14:28:36.000Z\n109`
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Fetch release information for non existing tag / release', async () => {
|
||||||
|
const configuration = resolveConfiguration(
|
||||||
|
'',
|
||||||
|
'configs_test/configuration_approvers.json'
|
||||||
|
)
|
||||||
|
configuration.template = "${{FROM_TAG}}-${{FROM_TAG_DATE}}\n${{TO_TAG}}-${{TO_TAG_DATE}}\n${{DAYS_SINCE}}"
|
||||||
|
const releaseNotesBuilder = new ReleaseNotesBuilder(
|
||||||
|
null, // baseUrl
|
||||||
|
null, // token
|
||||||
|
'.', // repoPath
|
||||||
|
'mikepenz', // user
|
||||||
|
'release-changelog-builder-action-playground', // repo
|
||||||
|
'2.0.0', // fromTag
|
||||||
|
'3.0.1', // toTag
|
||||||
|
true, // includeOpen
|
||||||
|
false, // failOnError
|
||||||
|
false, // ignorePrePrelease
|
||||||
|
false, // enable to fetch reviewers
|
||||||
|
true, // enable to fetch tag release information
|
||||||
|
false, // commitMode
|
||||||
|
configuration // configuration
|
||||||
|
)
|
||||||
|
|
||||||
|
const changeLog = await releaseNotesBuilder.build()
|
||||||
|
console.log(changeLog)
|
||||||
|
expect(changeLog).toStrictEqual(`- no changes`)
|
||||||
})
|
})
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"template": "${{CHANGELOG}}",
|
"template": "${{CHANGELOG}}\n\n${{DAYS_SINCE}}",
|
||||||
"pr_template": "- ${{TITLE}} -- (#${{NUMBER}}) [${{STATUS}}] ${{REVIEWERS}} --- ${{APPROVERS}}"
|
"pr_template": "- ${{TITLE}} -- (#${{NUMBER}}) [${{STATUS}}] ${{REVIEWERS}} --- ${{APPROVERS}}"
|
||||||
}
|
}
|
||||||
+6
-5
@@ -802,7 +802,7 @@ class ReleaseNotes {
|
|||||||
getCommitHistory(octokit) {
|
getCommitHistory(octokit) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const { owner, repo, fromTag, toTag, failOnError } = this.options;
|
const { owner, repo, fromTag, toTag, failOnError } = this.options;
|
||||||
core.info(`ℹ️ Comparing ${owner}/${repo} - '${fromTag}...${toTag}'`);
|
core.info(`ℹ️ Comparing ${owner}/${repo} - '${fromTag.name}...${toTag.name}'`);
|
||||||
const commitsApi = new commits_1.Commits(octokit);
|
const commitsApi = new commits_1.Commits(octokit);
|
||||||
let diffInfo;
|
let diffInfo;
|
||||||
try {
|
try {
|
||||||
@@ -813,7 +813,7 @@ class ReleaseNotes {
|
|||||||
return commits_1.DefaultDiffInfo;
|
return commits_1.DefaultDiffInfo;
|
||||||
}
|
}
|
||||||
if (diffInfo.commitInfo.length === 0) {
|
if (diffInfo.commitInfo.length === 0) {
|
||||||
core.warning(`⚠️ No commits found between - ${fromTag}...${toTag}`);
|
core.warning(`⚠️ No commits found between - ${fromTag.name}...${toTag.name}`);
|
||||||
return commits_1.DefaultDiffInfo;
|
return commits_1.DefaultDiffInfo;
|
||||||
}
|
}
|
||||||
return diffInfo;
|
return diffInfo;
|
||||||
@@ -1180,7 +1180,7 @@ class Tags {
|
|||||||
const response = yield this.octokit.request(options);
|
const response = yield this.octokit.request(options);
|
||||||
const release = response.data;
|
const release = response.data;
|
||||||
tagInfo.date = (0, moment_1.default)(release.created_at);
|
tagInfo.date = (0, moment_1.default)(release.created_at);
|
||||||
core.info(`ℹ️ Retrieved information about the release associated with ${tagInfo.name} from the GitHub API for ${owner}/${repo}`);
|
core.info(`ℹ️ Retrieved information about the release associated with ${tagInfo.name} from the GitHub API`);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.info(`⚠️ No release information found for ${tagInfo.name}, trying to retrieve tag creation time as fallback.`);
|
core.info(`⚠️ No release information found for ${tagInfo.name}, trying to retrieve tag creation time as fallback.`);
|
||||||
@@ -1191,6 +1191,9 @@ class Tags {
|
|||||||
tagInfo.date = creationTime;
|
tagInfo.date = creationTime;
|
||||||
core.info(`ℹ️ Resolved tag creation time (${creationTimeString}) from 'git for-each-ref --format="%(creatordate:rfc)" "refs/tags/${tagInfo.name}`);
|
core.info(`ℹ️ Resolved tag creation time (${creationTimeString}) from 'git for-each-ref --format="%(creatordate:rfc)" "refs/tags/${tagInfo.name}`);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
core.info(`⚠️ Could not retrieve tag creation time via git cli 'git for-each-ref --format="%(creatordate:rfc)" "refs/tags/${tagInfo.name}'`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return tagInfo;
|
return tagInfo;
|
||||||
});
|
});
|
||||||
@@ -1659,10 +1662,8 @@ function fillAdditionalPlaceholders(text, options) {
|
|||||||
transformed = transformed.replace(/\${{OWNER}}/g, options.owner);
|
transformed = transformed.replace(/\${{OWNER}}/g, options.owner);
|
||||||
transformed = transformed.replace(/\${{REPO}}/g, options.repo);
|
transformed = transformed.replace(/\${{REPO}}/g, options.repo);
|
||||||
transformed = transformed.replace(/\${{FROM_TAG}}/g, options.fromTag.name);
|
transformed = transformed.replace(/\${{FROM_TAG}}/g, options.fromTag.name);
|
||||||
transformed = transformed.replace(/\${{FROM_TAG_SHA}}/g, options.fromTag.commit || '');
|
|
||||||
transformed = transformed.replace(/\${{FROM_TAG_DATE}}/g, ((_a = options.fromTag.date) === null || _a === void 0 ? void 0 : _a.toISOString()) || '');
|
transformed = transformed.replace(/\${{FROM_TAG_DATE}}/g, ((_a = options.fromTag.date) === null || _a === void 0 ? void 0 : _a.toISOString()) || '');
|
||||||
transformed = transformed.replace(/\${{TO_TAG}}/g, options.toTag.name);
|
transformed = transformed.replace(/\${{TO_TAG}}/g, options.toTag.name);
|
||||||
transformed = transformed.replace(/\${{TO_TAG_SHA}}/g, options.toTag.commit || '');
|
|
||||||
transformed = transformed.replace(/\${{TO_TAG_DATE}}/g, ((_b = options.toTag.date) === null || _b === void 0 ? void 0 : _b.toISOString()) || '');
|
transformed = transformed.replace(/\${{TO_TAG_DATE}}/g, ((_b = options.toTag.date) === null || _b === void 0 ? void 0 : _b.toISOString()) || '');
|
||||||
const fromDate = options.fromTag.date;
|
const fromDate = options.fromTag.date;
|
||||||
const toDate = options.toTag.date;
|
const toDate = options.toTag.date;
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
+6
-2
@@ -80,7 +80,9 @@ export class ReleaseNotes {
|
|||||||
|
|
||||||
private async getCommitHistory(octokit: Octokit): Promise<DiffInfo> {
|
private async getCommitHistory(octokit: Octokit): Promise<DiffInfo> {
|
||||||
const {owner, repo, fromTag, toTag, failOnError} = this.options
|
const {owner, repo, fromTag, toTag, failOnError} = this.options
|
||||||
core.info(`ℹ️ Comparing ${owner}/${repo} - '${fromTag}...${toTag}'`)
|
core.info(
|
||||||
|
`ℹ️ Comparing ${owner}/${repo} - '${fromTag.name}...${toTag.name}'`
|
||||||
|
)
|
||||||
|
|
||||||
const commitsApi = new Commits(octokit)
|
const commitsApi = new Commits(octokit)
|
||||||
let diffInfo: DiffInfo
|
let diffInfo: DiffInfo
|
||||||
@@ -94,7 +96,9 @@ export class ReleaseNotes {
|
|||||||
return DefaultDiffInfo
|
return DefaultDiffInfo
|
||||||
}
|
}
|
||||||
if (diffInfo.commitInfo.length === 0) {
|
if (diffInfo.commitInfo.length === 0) {
|
||||||
core.warning(`⚠️ No commits found between - ${fromTag}...${toTag}`)
|
core.warning(
|
||||||
|
`⚠️ No commits found between - ${fromTag.name}...${toTag.name}`
|
||||||
|
)
|
||||||
return DefaultDiffInfo
|
return DefaultDiffInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-3
@@ -81,11 +81,9 @@ export class Tags {
|
|||||||
RestEndpointMethodTypes['repos']['getReleaseByTag']['response']['data']
|
RestEndpointMethodTypes['repos']['getReleaseByTag']['response']['data']
|
||||||
|
|
||||||
const release: ReleaseInformation = response.data as ReleaseInformation
|
const release: ReleaseInformation = response.data as ReleaseInformation
|
||||||
|
|
||||||
tagInfo.date = moment(release.created_at)
|
tagInfo.date = moment(release.created_at)
|
||||||
|
|
||||||
core.info(
|
core.info(
|
||||||
`ℹ️ Retrieved information about the release associated with ${tagInfo.name} from the GitHub API for ${owner}/${repo}`
|
`ℹ️ Retrieved information about the release associated with ${tagInfo.name} from the GitHub API`
|
||||||
)
|
)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.info(
|
core.info(
|
||||||
@@ -99,6 +97,10 @@ export class Tags {
|
|||||||
core.info(
|
core.info(
|
||||||
`ℹ️ Resolved tag creation time (${creationTimeString}) from 'git for-each-ref --format="%(creatordate:rfc)" "refs/tags/${tagInfo.name}`
|
`ℹ️ Resolved tag creation time (${creationTimeString}) from 'git for-each-ref --format="%(creatordate:rfc)" "refs/tags/${tagInfo.name}`
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
core.info(
|
||||||
|
`⚠️ Could not retrieve tag creation time via git cli 'git for-each-ref --format="%(creatordate:rfc)" "refs/tags/${tagInfo.name}'`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tagInfo
|
return tagInfo
|
||||||
|
|||||||
@@ -313,19 +313,11 @@ export function fillAdditionalPlaceholders(
|
|||||||
transformed = transformed.replace(/\${{OWNER}}/g, options.owner)
|
transformed = transformed.replace(/\${{OWNER}}/g, options.owner)
|
||||||
transformed = transformed.replace(/\${{REPO}}/g, options.repo)
|
transformed = transformed.replace(/\${{REPO}}/g, options.repo)
|
||||||
transformed = transformed.replace(/\${{FROM_TAG}}/g, options.fromTag.name)
|
transformed = transformed.replace(/\${{FROM_TAG}}/g, options.fromTag.name)
|
||||||
transformed = transformed.replace(
|
|
||||||
/\${{FROM_TAG_SHA}}/g,
|
|
||||||
options.fromTag.commit || ''
|
|
||||||
)
|
|
||||||
transformed = transformed.replace(
|
transformed = transformed.replace(
|
||||||
/\${{FROM_TAG_DATE}}/g,
|
/\${{FROM_TAG_DATE}}/g,
|
||||||
options.fromTag.date?.toISOString() || ''
|
options.fromTag.date?.toISOString() || ''
|
||||||
)
|
)
|
||||||
transformed = transformed.replace(/\${{TO_TAG}}/g, options.toTag.name)
|
transformed = transformed.replace(/\${{TO_TAG}}/g, options.toTag.name)
|
||||||
transformed = transformed.replace(
|
|
||||||
/\${{TO_TAG_SHA}}/g,
|
|
||||||
options.toTag.commit || ''
|
|
||||||
)
|
|
||||||
transformed = transformed.replace(
|
transformed = transformed.replace(
|
||||||
/\${{TO_TAG_DATE}}/g,
|
/\${{TO_TAG_DATE}}/g,
|
||||||
options.toTag.date?.toISOString() || ''
|
options.toTag.date?.toISOString() || ''
|
||||||
|
|||||||
Reference in New Issue
Block a user