Skip to content

Commit a599018

Browse files
raujaiswalazure-pipelines-bot
and
azure-pipelines-bot
authored
Fixes Release notes issue. (#5207)
* updating nodejs version in release template * Fix releaseNotes issue --------- Co-authored-by: azure-pipelines-bot <[email protected]>
1 parent 42701b8 commit a599018

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

.vsts.release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ extends:
194194
cd release
195195
npm install
196196
197-
node createReleaseBranch.js $(AgentVersion) --derivedFrom=${{ parameters.derivedFrom }}
197+
node createReleaseBranch.js $(AgentVersion) --derivedFrom=${{ parameters.derivedFrom }} --targetCommitId=$(Build.SourceVersion)
198198
env:
199199
EDITOR: cat
200200
PAT: $(GithubToken)

release/createReleaseBranch.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ var opt = require('node-getopt').create([
2929
['', 'dryrun', 'Dry run only, do not actually commit new release'],
3030
['', 'derivedFrom=version', 'Used to get PRs merged since this release was created', 'lastMinorRelease'],
3131
['', 'branch=branch', 'Branch to select PRs merged into', 'master'],
32+
['', 'targetCommitId=commit', 'Fetch PRs merged since this commit', ''],
3233
['h', 'help', 'Display this help'],
3334
])
3435
.setHelp(
@@ -68,6 +69,24 @@ function writeAgentVersionFile(newRelease) {
6869
return newRelease;
6970
}
7071

72+
function filterCommitsUpToTarget(commitList) {
73+
try{
74+
var targetCommitId = opt.options.targetCommitId;
75+
var targetIndex = commitList.indexOf(targetCommitId);
76+
77+
if (targetIndex === -1) {
78+
console.log(`Debug: Commit ID ${targetCommitId} not found in the list.`);
79+
return commitList;
80+
}
81+
// Return commits up to and including the target commit
82+
return commitList.slice(0, targetIndex + 1);
83+
}catch (e){
84+
console.log(e);
85+
console.error(`Unexpected error while filtering commits`);
86+
process.exit(-1);
87+
}
88+
}
89+
7190
async function fetchPRsForSHAsGraphQL(commitSHAs) {
7291

7392
var queryParts = commitSHAs.map((sha, index) => `
@@ -126,20 +145,20 @@ async function fetchPRsSincePreviousReleaseAndEditReleaseNotes(newRelease, callb
126145
var latestReleaseInfo = filteredReleases.find(release => release.tag_name.toLowerCase().startsWith(releaseTagPrefix.toLowerCase()));
127146
console.log(`Previous release tag with ${latestReleaseInfo.tag_name} and published date is: ${latestReleaseInfo.published_at}`)
128147

129-
var headBranchTag = 'v' + newRelease
130148
try {
131149
var comparison = await octokit.repos.compareCommits({
132150
owner: OWNER,
133151
repo: REPO,
134152
base: latestReleaseInfo.tag_name,
135-
head: headBranchTag,
153+
head: 'master',
136154
});
137155

138156
var commitSHAs = comparison.data.commits.map(commit => commit.sha);
157+
var filteredCommits = filterCommitsUpToTarget(commitSHAs);
139158

140159
try {
141160

142-
var allPRs = await fetchPRsForSHAsGraphQL(commitSHAs);
161+
var allPRs = await fetchPRsForSHAsGraphQL(filteredCommits);
143162
editReleaseNotesFile({ items: allPRs });
144163
} catch (e) {
145164
console.log(e);

0 commit comments

Comments
 (0)