From bd2830c4cfd75778d234eb96e77c7c990fd2adfd Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Wed, 18 Nov 2020 11:54:22 +0100 Subject: [PATCH] feat(events-sync): support repository renaming Handle event and update stored issues accordingly. --- packages/app/lib/apps/events-sync.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/packages/app/lib/apps/events-sync.js b/packages/app/lib/apps/events-sync.js index a899d828..b7f7e800 100644 --- a/packages/app/lib/apps/events-sync.js +++ b/packages/app/lib/apps/events-sync.js @@ -2,7 +2,9 @@ const { filterIssue, filterPull, filterIssueOrPull, - getIdentifier + filterRepository, + getIdentifier, + getKey } = require('../filters'); @@ -174,7 +176,25 @@ module.exports = function EventsSync(webhookEvents, store, logger) { // https://docs.github.com/en/free-pro-team@latest/developers/webhooks-and-events/webhook-events-and-payloads#repository webhookEvents.on([ - 'repository.renamed', + 'repository.renamed' + ], async ({ payload }) => { + + const { + repository + } = payload; + + await store.updateIssues(issue => { + + if (issue.repository.id === repository.id) { + return { + key: getKey(issue, repository), + repository: filterRepository(repository) + }; + } + }); + }); + + webhookEvents.on([ 'repository.transferred' ], async ({ payload }) => {