diff --git a/constants.ts b/constants.ts new file mode 100644 index 0000000..f4f352c --- /dev/null +++ b/constants.ts @@ -0,0 +1 @@ +export const INTERNAL_USERS = ["firgrep", "ridetoruin"]; diff --git a/cspell.json b/cspell.json index a11dda9..cc5d839 100644 --- a/cspell.json +++ b/cspell.json @@ -1,10 +1,21 @@ { "version": "0.2", - "ignorePaths": ["package.json", "package-lock.json"], + "ignorePaths": [ + "package.json", + "package-lock.json" + ], "dictionaryDefinitions": [], "dictionaries": [], - "words": ["autogit", "sphil"], - "enableFiletypes": ["mdx"], + "words": [ + "autogit", + "Firgrep", + "ridetoruin", + "sphil", + "systemphil" + ], + "enableFiletypes": [ + "mdx" + ], "ignoreWords": [ "biblatex", "datetime", diff --git a/index.ts b/index.ts index 37c3614..3f2a208 100644 --- a/index.ts +++ b/index.ts @@ -4,6 +4,7 @@ import { checkoutRepoPR, commitAndPushChanges, deleteRepo, + getTargetRepo, runPrettier, } from "./internals"; @@ -55,7 +56,7 @@ app.post("/gh", (req: Request, res: Response) => { return res.status(200).send("Webhook received"); } - const targetRepo = `${user}/sphil`; + const targetRepo = getTargetRepo(user); const ref = payload.pull_request.head.ref; const tempDir = crypto.randomUUID(); console.info( diff --git a/internals.ts b/internals.ts index 865e1b7..3c5d342 100644 --- a/internals.ts +++ b/internals.ts @@ -1,4 +1,5 @@ import { execSync } from "child_process"; +import { INTERNAL_USERS } from "./constants"; function deleteRepo(repo: string) { try { @@ -67,4 +68,17 @@ function commitAndPushChanges(tempDir: string, user: string) { } } -export { deleteRepo, checkoutRepoPR, runPrettier, commitAndPushChanges }; +function getTargetRepo(user: string): string { + if (INTERNAL_USERS.includes(user.toLowerCase())) { + return `systemphil/sphil`; + } + return `${user}/sphil`; +} + +export { + deleteRepo, + checkoutRepoPR, + runPrettier, + commitAndPushChanges, + getTargetRepo, +};