initial commit
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ic08e7c4b5b4f4072de9e2f9a701e977b6a6a6964
This commit is contained in:
commit
f8db097ba9
21 changed files with 4924 additions and 0 deletions
43
src/filters.ts
Normal file
43
src/filters.ts
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import type { FiltersConfig, WebhookEvent } from './types.js';
|
||||
|
||||
export function shouldProcess(
|
||||
event: WebhookEvent,
|
||||
filters: FiltersConfig
|
||||
): { pass: boolean; reason?: string } {
|
||||
// Label filters
|
||||
if (filters.labels.include.length > 0) {
|
||||
const hasRequired = event.labels.some((l) => filters.labels.include.includes(l));
|
||||
if (!hasRequired) {
|
||||
return { pass: false, reason: 'Missing required label' };
|
||||
}
|
||||
}
|
||||
|
||||
if (filters.labels.exclude.length > 0) {
|
||||
const hasExcluded = event.labels.some((l) => filters.labels.exclude.includes(l));
|
||||
if (hasExcluded) {
|
||||
return { pass: false, reason: 'Has excluded label' };
|
||||
}
|
||||
}
|
||||
|
||||
// Author filters
|
||||
if (filters.authors.include && filters.authors.include.length > 0) {
|
||||
if (!filters.authors.include.includes(event.author)) {
|
||||
return { pass: false, reason: 'Author not in include list' };
|
||||
}
|
||||
}
|
||||
|
||||
if (filters.authors.exclude.length > 0) {
|
||||
if (filters.authors.exclude.includes(event.author)) {
|
||||
return { pass: false, reason: 'Author is excluded' };
|
||||
}
|
||||
}
|
||||
|
||||
// Branch filters (PRs only)
|
||||
if (event.branch && filters.branches.include.length > 0) {
|
||||
if (!filters.branches.include.includes(event.branch)) {
|
||||
return { pass: false, reason: 'Branch not in include list' };
|
||||
}
|
||||
}
|
||||
|
||||
return { pass: true };
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue