harvester-ui-extension/scripts/extract-release-label.mjs
Andy Lee 25f9d0c6f1
ci: allow PR title to have parentheses
Signed-off-by: Andy Lee <andy.lee@suse.com>
2026-03-24 14:42:28 +08:00

19 lines
580 B
JavaScript

/* eslint-disable no-console */
import load from "@commitlint/load";
if (process.argv.length < 3) {
console.error('No PR title as first argument');
process.exit(1);
}
const prTitle = process.argv[2];
const match = prTitle.match(/^(\w+)(\(.+\))?:/);
const prLabel = match ? match[1].trim() : prTitle.split(':')[0].trim();
console.log('PR Label:', prLabel);
const config = await load({ extends: ["./commitlint.config.js"] });
const commitPrefix = config?.rules?.['type-enum']?.[2] || [];
const label = commitPrefix.includes(prLabel) ? prLabel : 'other';
console.log(label);