Repository navigation
Added a No-Issue escape hatch to the linked-issue check #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,12 @@ | ||
| // Matches the issue keys of our Linear teams, in any case. | ||
| const KEY = /\b(?:[KW][MPS]|[FINRSZ][AELMNP][FLQRSTWX])-\d+\b/i; | ||
|
|
||
| // A body line such as "No-Issue: typo fix" explains why the PR has no issue. | ||
| const NO_ISSUE = /^No-Issue:[ \t]*(\S.*)$/im; | ||
|
|
||
| // HTML comments, such as PR template hints, do not render. An unclosed one hides the rest. | ||
| const HTML_COMMENT = /<!--[\s\S]*?(?:-->|$)/g; | ||
|
|
||
| // join() turns a null body into an empty string. | ||
| function hasLinearKey(title, body, branch) { | ||
| return KEY.test([title, body, branch].join('\n')); | ||
|
|
@@ -12,4 +18,10 @@ function isBot(user) { | |
| return user.type === 'Bot'; | ||
| } | ||
|
|
||
| module.exports = { hasLinearKey, isBot }; | ||
| // Returns the No-Issue reason from the body, or null if there is none. | ||
| function noIssueReason(body) { | ||
| const match = NO_ISSUE.exec((body ?? '').replace(HTML_COMMENT, '')); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Preserve line breaks when removing HTML comments. For
|
||
| return match ? match[1].trim() : null; | ||
| } | ||
|
|
||
| module.exports = { hasLinearKey, isBot, noIssueReason }; | ||
Uh oh!
There was an error while loading. Please reload this page.