-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(semantic-pr-footer): allow omission of colon in footer prefixes (#…
- Loading branch information
Showing
4 changed files
with
79 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 25 additions & 21 deletions
46
.github/actions/semantic-pr-footer-v1/src/isValidFooter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,30 @@ | ||
const validFooters = [ | ||
// github terms that link an issue | ||
// These must appear with a suffix (eg, "fix #123" or "QA Notes: test X, Y, and Z") | ||
const validFooterPrefixes = [ | ||
// Should accept all github terms that link an issue | ||
// @see https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword | ||
'close: ', | ||
'closes: ', | ||
'closed: ', | ||
'fix: ', | ||
'fixes: ', | ||
'fixed: ', | ||
'resolve: ', | ||
'resolves: ', | ||
'resolved: ', | ||
|
||
// additional allowed terms | ||
'ref: ', | ||
'refs: ', | ||
'qa notes: ', | ||
'no qa required', | ||
'no qa needed' | ||
'close', | ||
'closes', | ||
'closed', | ||
'fix', | ||
'fixes', | ||
'fixed', | ||
'resolve', | ||
'resolves', | ||
'resolved', | ||
// Additional allowed terms | ||
'ref', | ||
'refs', | ||
'qa notes' | ||
] | ||
|
||
export default function isValidFooter(footer: string): boolean { | ||
footer = footer.toLowerCase() | ||
// These may appear alone or with a suffix (eg, "no qa needed" or "no qa needed (test only)") | ||
const validFooters = ['no qa needed', 'no qa required'] | ||
|
||
return validFooters.some(term => footer.startsWith(term)) | ||
const validFooterPrefixRegex = new RegExp( | ||
`^(${validFooterPrefixes.join('|')}):? `, | ||
'i' | ||
) | ||
const validFooterRegex = new RegExp(`^(${validFooters.join('|')})`, 'i') | ||
export default function isValidFooter(footer: string): boolean { | ||
return validFooterRegex.test(footer) || validFooterPrefixRegex.test(footer) | ||
} |