Skip to content

Commit

Permalink
fix: support for internals
Browse files Browse the repository at this point in the history
  • Loading branch information
Firgrep committed Sep 28, 2024
1 parent 08e83f2 commit dc9323c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
1 change: 1 addition & 0 deletions constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const INTERNAL_USERS = ["firgrep", "ridetoruin"];
17 changes: 14 additions & 3 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
3 changes: 2 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
checkoutRepoPR,
commitAndPushChanges,
deleteRepo,
getTargetRepo,
runPrettier,
} from "./internals";

Expand Down Expand Up @@ -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(
Expand Down
16 changes: 15 additions & 1 deletion internals.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { execSync } from "child_process";
import { INTERNAL_USERS } from "./constants";

function deleteRepo(repo: string) {
try {
Expand Down Expand Up @@ -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,
};

0 comments on commit dc9323c

Please sign in to comment.