Skip to content

Commit d41c216

Browse files
committed
fin tune change log
1 parent c212577 commit d41c216

File tree

3 files changed

+146
-5
lines changed

3 files changed

+146
-5
lines changed

apps/download/changelog.cfc

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,26 @@ component {
137137
// Determine previous version for changelog range
138138
if ( idx lt arrayLen( arguments.arrVersions ) ) {
139139
prevVersion = arguments.versions[ arguments.arrVersions[ idx + 1 ] ].version;
140+
141+
// If current version is a stable release, check if there's an RC/Beta/Alpha with same base version
142+
if ( arguments.versions[ _version ].type eq "releases" ) {
143+
var baseVersion = listFirst( version, "-" );
144+
//systemOutput( "Stable release #version#: looking for RC/Beta/Alpha with base version #baseVersion#, current prevVersion=#prevVersion#", true );
145+
// Look through all versions to find RC/Beta/Alpha with matching base
146+
loop array=arguments.arrVersions index="local.checkIdx" item="local.checkKey" {
147+
var checkVersion = arguments.versions[ checkKey ].version;
148+
var checkType = arguments.versions[ checkKey ].type;
149+
var checkBase = listFirst( checkVersion, "-" );
150+
// If we find an RC/Beta/Alpha with the same base version, use it as prevVersion
151+
if ( ( checkType eq "rc" || checkType eq "beta" || checkType eq "alpha" )
152+
&& checkBase eq baseVersion ) {
153+
//systemOutput( "Found match: #checkVersion# (type=#checkType#, base=#checkBase#), setting as prevVersion", true );
154+
prevVersion = checkVersion;
155+
break;
156+
}
157+
}
158+
//systemOutput( "Final prevVersion for stable #version# is #prevVersion#", true );
159+
}
140160
} else {
141161
// Last version - use the oldest version from the sorted array (last item)
142162
var lastKey = arguments.arrVersions[ arrayLen( arguments.arrVersions ) ];
@@ -157,7 +177,12 @@ component {
157177
var changelog = {};
158178
var versionReleaseDate = "";
159179
if ( left( version, len( arguments.majorVersionFilter ) ) eq arguments.majorVersionFilter ) {
160-
changelog = variables.download.getChangelog( prevVersion, version, false, true );
180+
// For RC/Beta/Alpha, use the base version (without suffix) as upper bound to include tickets tagged without suffix
181+
var changelogVersion = version;
182+
if ( arguments.versions[ _version ].type eq "rc" || arguments.versions[ _version ].type eq "beta" || arguments.versions[ _version ].type eq "alpha" ) {
183+
changelogVersion = listFirst( version, "-" );
184+
}
185+
changelog = variables.download.getChangelog( prevVersion, changelogVersion, false, true );
161186
versionReleaseDate = variables.download.getReleaseDate( version );
162187
}
163188

@@ -180,6 +205,61 @@ component {
180205
return arrChangeLogs;
181206
}
182207

208+
/**
209+
* Remove duplicate tickets from stable releases that also appear in their RC/Beta/Alpha
210+
* Handles two cases:
211+
* 1. Same base version (e.g., 6.2.3.35 stable and 6.2.3.35-RC)
212+
* 2. Different base version where stable's prevVersion is RC/Beta/Alpha (e.g., 6.2.2.91 stable with prevVersion 6.2.2.90-RC)
213+
* @arrChangeLogs The changelog data array from buildChangelogData
214+
* @returns The deduplicated changelog data array
215+
*/
216+
function deduplicateStableReleaseTickets( required array arrChangeLogs ) localmode=true {
217+
// Build a lookup map by version for quick access
218+
versionLookup = {};
219+
loop array=arguments.arrChangeLogs index="changelog" {
220+
versionLookup[ changelog.version ] = changelog;
221+
}
222+
223+
// Process each stable release
224+
loop array=arguments.arrChangeLogs index="changelog" {
225+
if ( changelog.type eq "releases" && structCount( changelog.changelog ) > 0 ) {
226+
stableRelease = changelog;
227+
prevVersion = stableRelease.prevVersion;
228+
229+
// Check if prevVersion is an RC/Beta/Alpha
230+
isPrevRC = ( findNoCase( "-rc", prevVersion ) || findNoCase( "-beta", prevVersion ) || findNoCase( "-alpha", prevVersion ) );
231+
232+
// If prevVersion is RC/Beta/Alpha and exists in our data, deduplicate
233+
if ( isPrevRC && structKeyExists( versionLookup, prevVersion ) ) {
234+
rcRelease = versionLookup[ prevVersion ];
235+
236+
if ( structCount( rcRelease.changelog ) > 0 ) {
237+
// Build a list of all ticket IDs in the RC changelog
238+
rcTicketIds = {};
239+
loop collection=rcRelease.changelog index="ver" item="tickets" {
240+
loop collection=tickets index="ticketId" item="ticketData" {
241+
rcTicketIds[ ticketId ] = true;
242+
}
243+
}
244+
245+
// Remove those tickets from the stable changelog
246+
loop collection=stableRelease.changelog index="ver" item="tickets" {
247+
ticketsToKeep = {};
248+
loop collection=tickets index="ticketId" item="ticketData" {
249+
if ( !structKeyExists( rcTicketIds, ticketId ) ) {
250+
ticketsToKeep[ ticketId ] = ticketData;
251+
}
252+
}
253+
stableRelease.changelog[ ver ] = ticketsToKeep;
254+
}
255+
}
256+
}
257+
}
258+
}
259+
260+
return arguments.arrChangeLogs;
261+
}
262+
183263
/**
184264
* Convert a version string to sortable format (from VersionUtils.cfc logic)
185265
* @version Version string like "7.0.1.44-SNAPSHOT"

apps/download/changelog/index.cfm

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@
7373
// Build changelog data array using the new method
7474
arrChangeLogs = changelogService.buildChangelogData( major, arrVersions, url.version );
7575
76+
// Remove duplicate tickets from stable releases that also appear in their RC/Beta/Alpha
77+
arrChangeLogs = changelogService.deduplicateStableReleaseTickets( arrChangeLogs );
78+
7679
function getBadgeForType( type ) {
7780
switch(arguments.type){
7881
case "bug":
@@ -227,10 +230,12 @@
227230
</div>
228231
</cfif>
229232
</td>
230-
<td style="max-width:250px;" data-fix-versions="#encodeForHtmlAttribute(arrayToList(ticket.fixVersions, ', '))#"
231-
title="Fixed in versions: #arrayToList(ticket.fixVersions, ', ')#">
232-
<cfloop array="#ticket.fixVersions#" item="fixVersion" index="i">
233-
<span data-git-tag="https://github.com/lucee/Lucee/tree/#listFirst(fixVersion, '-')#">#fixVersion#</span><cfif i lt arrayLen(ticket.fixVersions)>, </cfif>
233+
<cfset sortedFixVersions = duplicate(ticket.fixVersions)>
234+
<cfset sortedFixVersions.sort("text")>
235+
<td style="max-width:250px;" data-fix-versions="#encodeForHtmlAttribute(arrayToList(sortedFixVersions, ', '))#"
236+
title="Fixed in versions: #arrayToList(sortedFixVersions, ', ')#">
237+
<cfloop array="#sortedFixVersions#" item="fixVersion" index="i">
238+
<a href="https://github.com/lucee/Lucee/commits/#listFirst(fixVersion, '-')#/" target="_blank" title="View commits for #fixVersion# on GitHub">#fixVersion#</a><cfif i lt arrayLen(sortedFixVersions)>, </cfif>
234239
</cfloop>
235240
</td>
236241
</tr>

tests/testChangelog.cfc

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,62 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="data-provider" {
199199
expect( result[ 3 ].prevVersion ).toBe( "7.0.0.388-RC" );
200200
});
201201

202+
it( "should use RC as prevVersion for stable release with same base version", function() {
203+
var versions = {
204+
"06.002.003.0035.100": {
205+
"version": "6.2.3.35",
206+
"type": "releases"
207+
},
208+
"06.002.003.0035.075": {
209+
"version": "6.2.3.35-RC",
210+
"type": "rc"
211+
},
212+
"06.002.003.0034.100": {
213+
"version": "6.2.3.34",
214+
"type": "releases"
215+
}
216+
};
217+
218+
var arrVersions = [ "06.002.003.0035.100", "06.002.003.0035.075", "06.002.003.0034.100" ];
219+
220+
var result = changelog.buildChangelogData( versions, arrVersions, "6.2" );
221+
222+
// Stable 6.2.3.35 should use RC 6.2.3.35-RC as prevVersion, not 6.2.3.34
223+
expect( result[ 1 ].version ).toBe( "6.2.3.35" );
224+
expect( result[ 1 ].type ).toBe( "releases" );
225+
expect( result[ 1 ].prevVersion ).toBe( "6.2.3.35-RC" );
226+
227+
// RC should use stable 6.2.3.34 as prevVersion
228+
expect( result[ 2 ].version ).toBe( "6.2.3.35-RC" );
229+
expect( result[ 2 ].type ).toBe( "rc" );
230+
expect( result[ 2 ].prevVersion ).toBe( "6.2.3.34" );
231+
});
232+
233+
it( "should use beta as prevVersion for stable release when no RC exists", function() {
234+
var versions = {
235+
"06.002.003.0035.100": {
236+
"version": "6.2.3.35",
237+
"type": "releases"
238+
},
239+
"06.002.003.0035.050": {
240+
"version": "6.2.3.35-BETA",
241+
"type": "beta"
242+
},
243+
"06.002.003.0034.100": {
244+
"version": "6.2.3.34",
245+
"type": "releases"
246+
}
247+
};
248+
249+
var arrVersions = [ "06.002.003.0035.100", "06.002.003.0035.050", "06.002.003.0034.100" ];
250+
251+
var result = changelog.buildChangelogData( versions, arrVersions, "6.2" );
252+
253+
// Stable 6.2.3.35 should use BETA 6.2.3.35-BETA as prevVersion
254+
expect( result[ 1 ].version ).toBe( "6.2.3.35" );
255+
expect( result[ 1 ].prevVersion ).toBe( "6.2.3.35-BETA" );
256+
});
257+
202258
});
203259
}
204260

0 commit comments

Comments
 (0)