Skip to content

Commit

Permalink
feat(events-sync): support repository renaming
Browse files Browse the repository at this point in the history
Handle <repository.renamed> event and update stored issues accordingly.
  • Loading branch information
nikku committed Nov 18, 2020
1 parent f8cff49 commit bd2830c
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions packages/app/lib/apps/events-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ const {
filterIssue,
filterPull,
filterIssueOrPull,
getIdentifier
filterRepository,
getIdentifier,
getKey
} = require('../filters');


Expand Down Expand Up @@ -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 }) => {

Expand Down

0 comments on commit bd2830c

Please sign in to comment.