@@ -29,6 +29,7 @@ var opt = require('node-getopt').create([
29
29
[ '' , 'dryrun' , 'Dry run only, do not actually commit new release' ] ,
30
30
[ '' , 'derivedFrom=version' , 'Used to get PRs merged since this release was created' , 'lastMinorRelease' ] ,
31
31
[ '' , 'branch=branch' , 'Branch to select PRs merged into' , 'master' ] ,
32
+ [ '' , 'targetCommitId=commit' , 'Fetch PRs merged since this commit' , '' ] ,
32
33
[ 'h' , 'help' , 'Display this help' ] ,
33
34
] )
34
35
. setHelp (
@@ -68,6 +69,24 @@ function writeAgentVersionFile(newRelease) {
68
69
return newRelease ;
69
70
}
70
71
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
+
71
90
async function fetchPRsForSHAsGraphQL ( commitSHAs ) {
72
91
73
92
var queryParts = commitSHAs . map ( ( sha , index ) => `
@@ -126,20 +145,20 @@ async function fetchPRsSincePreviousReleaseAndEditReleaseNotes(newRelease, callb
126
145
var latestReleaseInfo = filteredReleases . find ( release => release . tag_name . toLowerCase ( ) . startsWith ( releaseTagPrefix . toLowerCase ( ) ) ) ;
127
146
console . log ( `Previous release tag with ${ latestReleaseInfo . tag_name } and published date is: ${ latestReleaseInfo . published_at } ` )
128
147
129
- var headBranchTag = 'v' + newRelease
130
148
try {
131
149
var comparison = await octokit . repos . compareCommits ( {
132
150
owner : OWNER ,
133
151
repo : REPO ,
134
152
base : latestReleaseInfo . tag_name ,
135
- head : headBranchTag ,
153
+ head : 'master' ,
136
154
} ) ;
137
155
138
156
var commitSHAs = comparison . data . commits . map ( commit => commit . sha ) ;
157
+ var filteredCommits = filterCommitsUpToTarget ( commitSHAs ) ;
139
158
140
159
try {
141
160
142
- var allPRs = await fetchPRsForSHAsGraphQL ( commitSHAs ) ;
161
+ var allPRs = await fetchPRsForSHAsGraphQL ( filteredCommits ) ;
143
162
editReleaseNotesFile ( { items : allPRs } ) ;
144
163
} catch ( e ) {
145
164
console . log ( e ) ;
0 commit comments