INNER CODE UNIT · JavaScript
match
scality/Zenko · .github/scripts/get-previous-tag.js:7
const match = version.match(/([-.])[^-.]+$/);
if (!match) {
return undefined;
}
const separator = match[1];
const prefix = version.substring(0, match.index);
version = prefix;
// Look for a "direct sibling" at this level: a tag shaped exactly
// `<prefix><separator><segment>` with no further separators. This
// excludes side-branch tags (hotfix X.Y.Z-N or X.Y.Z.N) from being
// picked as the predecessor of a main-line release (X.Y.Z).
const stem = prefix + separator;
const previous_tags = allReleases.filter(r =>
r.tag_name.startsWith(stem) &&
!/[-.]/.test(r.tag_name.substring(stem.length))
);
if (previous_tags.length > 0) {