Skip to content

Commit

Permalink
Enable MergeConflictChecker plugin for esphome/esphome (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored Dec 21, 2023
1 parent 0e56419 commit 88021b6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion services/bots/src/github-webhook/github-webhook.const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@ export type GetIssueLabelResponse =
export type PullRequestCreateReviewParams =
RestEndpointMethodTypes['pulls']['createReview']['parameters'];

export type Repository = HomeAssistantRepository;
export type Repository = HomeAssistantRepository | ESPHomeRepository;

export enum Organization {
ESPHOME = 'esphome',
HOME_ASSISTANT = 'home-assistant',
}

export enum ESPHomeRepository {
ESPHOME = 'esphome/esphome',
}

export enum HomeAssistantRepository {
ADDONS = 'home-assistant/addons',
ANDROID = 'home-assistant/android',
Expand Down
4 changes: 2 additions & 2 deletions services/bots/src/github-webhook/handlers/merge_conflict.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { PullRequestOpenedEvent, PullRequestSynchronizeEvent } from '@octokit/webhooks-types';
import { EventType, HomeAssistantRepository } from '../github-webhook.const';
import { ESPHomeRepository, EventType, HomeAssistantRepository } from '../github-webhook.const';
import { WebhookContext } from '../github-webhook.model';
import { BaseWebhookHandler } from './base';

export class MergeConflictChecker extends BaseWebhookHandler {
public allowedEventTypes = [EventType.PULL_REQUEST_OPENED, EventType.PULL_REQUEST_SYNCHRONIZE];
public allowedRepositories = [HomeAssistantRepository.CORE];
public allowedRepositories = [HomeAssistantRepository.CORE, ESPHomeRepository.ESPHOME];

async handle(context: WebhookContext<PullRequestOpenedEvent | PullRequestSynchronizeEvent>) {
// The data in the event is stale, so we need to re-fetch it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ describe('GithubWebhookModule', () => {
},
{
eventType: EventType.PULL_REQUEST_OPENED,
handlers: [],
handlers: ['MergeConflictChecker'],
payload: {
repository: { full_name: 'esphome/esphome', owner: { login: 'esphome' } },
},
Expand Down Expand Up @@ -173,7 +173,7 @@ describe('GithubWebhookModule', () => {
},
{
eventType: EventType.PULL_REQUEST_SYNCHRONIZE,
handlers: [],
handlers: ['MergeConflictChecker'],
payload: {
repository: { full_name: 'esphome/esphome', owner: { login: 'esphome' } },
},
Expand Down

0 comments on commit 88021b6

Please sign in to comment.