Skip to content

Commit b474d64

Browse files
authored
fix: parse SNAPSHOT versions with extra qualifier segments (#24931)
setVersion only matched the \d+.\d+-SNAPSHOT shape, so a version with an extra qualifier such as 25.3.tsclient-SNAPSHOT produced no match and crashed on null[2], taking down the whole CI matrix computation before any job ran. Broaden the pattern to any -SNAPSHOT version and guard against a missing match so a mismatch degrades gracefully.
1 parent 626a502 commit b474d64

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

‎scripts/computeMatrix.js‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,15 @@ function getFiles(files, folder, pattern) {
238238
*/
239239
function setVersion(newVersion) {
240240
const pomContent = fs.readFileSync('pom.xml').toString();
241-
const current = RegExp(regexVersion.replace('VERSION', '\\d+\\.\\d+\\-SNAPSHOT')).exec(pomContent)[2];
242-
if (current && current != newVersion) {
241+
// Match any SNAPSHOT version, including extra qualifier segments such as
242+
// `25.3.tsclient-SNAPSHOT`, not just the `\d+\.\d+-SNAPSHOT` shape.
243+
const match = RegExp(regexVersion.replace('VERSION', '[\\w.\\-]+?-SNAPSHOT')).exec(pomContent);
244+
const current = match && match[2];
245+
if (!current) {
246+
console.log('No SNAPSHOT version found in pom.xml, nothing to replace');
247+
return;
248+
}
249+
if (current != newVersion) {
243250
const regexChangeVersion = RegExp(regexVersion.replace('VERSION', current), 'g');
244251
const files = getFiles([], '.', /.*\/pom.*\.xml$/);
245252
files.forEach(file => {

0 commit comments

Comments
 (0)