Skip to content

Commit

Permalink
Handle when the github user is not in the USER_MAP. (#106)
Browse files Browse the repository at this point in the history
* Handle when the github user is not in the USER_MAP.

* Update dist
  • Loading branch information
sammacbeth authored Mar 7, 2024
1 parent 7710ad7 commit bb40a07
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
19 changes: 12 additions & 7 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

23 changes: 15 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ const SKIPPED_USERS_LIST = SKIPPED_USERS.split(',')
const NO_AUTOCLOSE_PROJECTS = getInput('NO_AUTOCLOSE_PROJECTS')
const NO_AUTOCLOSE_LIST = NO_AUTOCLOSE_PROJECTS.split(',')

function getUserFromLogin(login: string): string {
let mail = MAIL_MAP[login]
function getUserFromLogin(login: string): string | null {
const mail = MAIL_MAP[login]
if (mail === undefined) {
// Fall back to matching logins
mail = login
// Ignore unknown
return null
}
return `${mail}@duckduckgo.com`
}
Expand All @@ -58,10 +58,11 @@ async function createOrReopenReviewSubtask(
const payload = context.payload as PullRequestEvent
const title = payload.pull_request.title
// const subtasks = await client.tasks.subtasks(taskId)
const author = getUserFromLogin(payload.pull_request.user.login)
const githubAuthor = payload.pull_request.user.login
const author = getUserFromLogin(githubAuthor)
const reviewerEmail = getUserFromLogin(reviewer)
info(`Review requested from ${reviewer} (${reviewerEmail})`)
if (SKIPPED_USERS_LIST.includes(reviewer)) {
if (SKIPPED_USERS_LIST.includes(reviewer) || reviewerEmail === null) {
info(
`Skipping review subtask creation for ${reviewer} - member of SKIPPED_USERS`
)
Expand All @@ -86,16 +87,22 @@ async function createOrReopenReviewSubtask(
}
}
info(`Subtask for ${reviewerEmail}: ${JSON.stringify(reviewSubtask)}`)
const taskFollowers = [reviewerEmail]
if (author !== null) {
taskFollowers.push(author)
}
const subtaskObj = {
name: `Review Request: ${title}`,
notes: `${author} requested your code review of ${payload.pull_request.html_url}.
notes: `${author || githubAuthor} requested your code review of ${
payload.pull_request.html_url
}.
NOTE:
* This task will be automatically closed when the review is completed in Github
See parent task for more information`,
assignee: reviewerEmail,
followers: [author, reviewerEmail]
followers: taskFollowers
}
if (!reviewSubtask) {
info(`Author: ${author}`)
Expand Down

0 comments on commit bb40a07

Please sign in to comment.