-
Notifications
You must be signed in to change notification settings - Fork 7
Fix Slack notification snippet #45
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 4 commits
be91fcc
670bedf
144958e
d7dcf74
e93df69
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 |
|---|---|---|
|
|
@@ -170,11 +170,78 @@ async function hasRecentBotComment( | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Checks if an issue has a label with the given name (case-insensitive). | ||
| */ | ||
| async function hasLabel(name, owner, repo, issueNumber, github, core) { | ||
| let labels = []; | ||
| try { | ||
| const response = await github.rest.issues.listLabelsOnIssue({ | ||
| owner, | ||
| repo, | ||
| issue_number: issueNumber, | ||
| }); | ||
| labels = response.data.map(label => label.name); | ||
| } catch (error) { | ||
| core.warning(`Failed to fetch labels on issue #${issueNumber}: ${error.message}`); | ||
| labels = []; | ||
| } | ||
| return labels.some(label => label.toLowerCase() === name.toLowerCase()); | ||
| } | ||
|
|
||
| /** | ||
| * Fetches issues assigned to an assignee in given repositories. | ||
| */ | ||
| async function getIssues(assignee, state, owner, repos, github, core) { | ||
| const promises = repos.map(repo => | ||
| github.rest.issues | ||
| .listForRepo({ | ||
|
Member
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. Same for this and
Member
Author
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. Yes, I will have a look |
||
| owner, | ||
| repo, | ||
| assignee, | ||
| state, | ||
| }) | ||
| .then(response => response.data.filter(issue => !issue.pull_request)) | ||
| .catch(error => { | ||
| core.warning(`Failed to fetch issues from ${repo}: ${error.message}`); | ||
| return []; | ||
| }), | ||
| ); | ||
|
|
||
| const results = await Promise.all(promises); | ||
| return results.flat(); | ||
| } | ||
|
|
||
| /** | ||
| * Fetches pull requests by an author in given repositories. | ||
| */ | ||
| async function getPullRequests(author, state, owner, repos, github, core) { | ||
| const promises = repos.map(repo => | ||
| github.rest.pulls | ||
| .list({ | ||
| owner, | ||
| repo, | ||
| state, | ||
| }) | ||
| .then(response => response.data.filter(pr => pr.user.login === author)) | ||
| .catch(error => { | ||
| core.warning(`Failed to fetch pull requests from ${repo}: ${error.message}`); | ||
| return []; | ||
| }), | ||
| ); | ||
|
|
||
| const results = await Promise.all(promises); | ||
| return results.flat(); | ||
| } | ||
|
|
||
| module.exports = { | ||
| isContributor, | ||
| isCloseContributor, | ||
| isBot, | ||
| sendBotMessage, | ||
| escapeIssueTitleForSlackMessage, | ||
| hasRecentBotComment, | ||
| hasLabel, | ||
| getIssues, | ||
| getPullRequests, | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one question here the data received is it paginated? Do we get all the issues in one go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're fetching only one issue here - by the issue number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for labels, I will look into it