Skip to content

Commit

Permalink
Merge pull request #5 from gooddata/jimi/lint
Browse files Browse the repository at this point in the history
fix(commit-lint): make commit-lint more robust
  • Loading branch information
jimirocks authored Jun 17, 2024
2 parents e8737ac + 9bea2b8 commit 63152f4
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions .github/workflows/commit-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,19 @@ jobs:
const { type, subject } = parsedCommit;
if (type === 'chore' && subject?.startsWith('update')) return [true]; // skip renovate and extimage bumps

const trailers = execSync('git interpret-trailers --parse', {
input: parsedCommit.raw || '',
}).toString();
const matches = toLines(trailers).filter((ln) => ln.match(/^risk:\s*nonprod|low|high/i)).length
return [
matches === 1,
`Should have exactly one risk label of value nonprod|low|high, but ${matches} found.`,
];
try {
const trailers = execSync('git interpret-trailers', ['--parse'], {
input: parsedCommit.raw || '',
}).toString();
const matches = toLines(trailers)?.filter((ln) => ln.match(/^risk:\s*nonprod|low|high/i))?.length
return [
matches === 1,
`Should have exactly one risk label of value nonprod|low|high, but ${matches} found.`,
];
} catch (err) {
console.error(err.toString());
return [false, 'Error while trying to find risk label'];
}
},
},
},
Expand Down

0 comments on commit 63152f4

Please sign in to comment.