Skip to content
This repository has been archived by the owner on Jul 1, 2024. It is now read-only.

Commit

Permalink
Enforce remove/Recently Merged on close/merge
Browse files Browse the repository at this point in the history
  • Loading branch information
jablko committed Feb 1, 2021
1 parent 617c945 commit 5105d41
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/compute-pr-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,24 @@ export const LabelNames = [
...StalenessKinds,
] as const;

export interface Actions {
projectColumn?: ColumnName | "*REMOVE*";
export type Actions = {
labels: LabelName[];
responseComments: Comments.Comment[];
state?: "close" | "merge";
shouldUpdateLabels: boolean;
}
} & (
| {
state?: never;
projectColumn?: ColumnName | "*REMOVE*";
}
| {
state: "close";
projectColumn: "*REMOVE*";
}
| {
state: "merge";
projectColumn: "Recently Merged";
}
);

function createDefaultActions(): Actions {
return {
Expand All @@ -65,14 +76,6 @@ function createDefaultActions(): Actions {
};
}

function createEmptyActions(): Actions {
return {
labels: [],
responseComments: [],
shouldUpdateLabels: false,
};
}

type Staleness = {
readonly kind: StalenessKind;
readonly days: number;
Expand Down Expand Up @@ -223,7 +226,9 @@ export function process(prInfo: BotResult,
extendedCallback: (info: ExtendedPrInfo) => void = _i => {}): Actions {
if (prInfo.type === "remove") {
return {
...createEmptyActions(),
labels: [],
responseComments: [],
shouldUpdateLabels: false,
projectColumn: prInfo.isDraft ? "Needs Author Action" : "*REMOVE*",
};
}
Expand Down

0 comments on commit 5105d41

Please sign in to comment.