File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,6 +18,17 @@ const https = require("https");
1818
1919const CONFIG_URL = "https://raw.githubusercontent.com/github/gh-aw/main/config.json" ;
2020
21+ /**
22+ * Normalize a version string by stripping the leading "v" prefix if present.
23+ * This ensures "v1.0.0" and "1.0.0" are treated as equivalent.
24+ *
25+ * @param {string } version
26+ * @returns {string }
27+ */
28+ function normalizeVersion ( version ) {
29+ return version . startsWith ( "v" ) ? version . slice ( 1 ) : version ;
30+ }
31+
2132/**
2233 * Parse a semver-like version string into an array of numeric parts.
2334 * Strips a leading "v" if present.
@@ -114,8 +125,9 @@ async function main() {
114125 const blockedVersions = Array . isArray ( config . blockedVersions ) ? config . blockedVersions : [ ] ;
115126 const minimumVersion = typeof config . minimumVersion === "string" ? config . minimumVersion : "" ;
116127
117- // Check blocked versions
118- if ( blockedVersions . includes ( compiledVersion ) ) {
128+ // Check blocked versions (normalize both sides to ignore leading "v" prefix)
129+ const normalizedCompiled = normalizeVersion ( compiledVersion ) ;
130+ if ( blockedVersions . some ( v => normalizeVersion ( v ) === normalizedCompiled ) ) {
119131 core . summary
120132 . addRaw ( "### ❌ Blocked compile-agentic version\n\n" )
121133 . addRaw ( `The compile-agentic version \`${ compiledVersion } \` is **blocked** and cannot be used to run workflows.\n\n` )
Original file line number Diff line number Diff line change @@ -170,12 +170,20 @@ describe("check_version_updates", () => {
170170 expect ( mockCore . setFailed ) . not . toHaveBeenCalled ( ) ;
171171 } ) ;
172172
173- it ( "should handle version strings without leading 'v'" , async ( ) => {
173+ it ( "should block version when config uses version without 'v' prefix " , async ( ) => {
174174 process . env . GH_AW_COMPILED_VERSION = "v1.0.0" ;
175175 mockHttpsSuccess ( JSON . stringify ( { blockedVersions : [ "1.0.0" ] , minimumVersion : "" } ) ) ;
176- // "v1.0.0" is NOT in [ "1.0.0"] because includes() uses exact string match
176+ // "v1.0.0" should be blocked by "1.0.0" after normalization
177177 await checkVersionUpdates . main ( ) ;
178- expect ( mockCore . setFailed ) . not . toHaveBeenCalled ( ) ;
178+ expect ( mockCore . setFailed ) . toHaveBeenCalledWith ( expect . stringContaining ( "Blocked compile-agentic version" ) ) ;
179+ } ) ;
180+
181+ it ( "should block version regardless of 'v' prefix in compiled version" , async ( ) => {
182+ process . env . GH_AW_COMPILED_VERSION = "1.0.0" ;
183+ mockHttpsSuccess ( JSON . stringify ( { blockedVersions : [ "v1.0.0" ] , minimumVersion : "" } ) ) ;
184+ // "1.0.0" should be blocked by "v1.0.0" after normalization
185+ await checkVersionUpdates . main ( ) ;
186+ expect ( mockCore . setFailed ) . toHaveBeenCalledWith ( expect . stringContaining ( "Blocked compile-agentic version" ) ) ;
179187 } ) ;
180188
181189 it ( "should fail when version is blocked with exact string match" , async ( ) => {
You can’t perform that action at this time.
0 commit comments