From 8839141f16b6bcccfdea8c93c3814c3171e4014c Mon Sep 17 00:00:00 2001 From: edideaur Date: Sat, 31 Jan 2026 18:46:34 +0000 Subject: [PATCH] add git pull path --- index.ts | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/index.ts b/index.ts index 11e9744..e720a2e 100644 --- a/index.ts +++ b/index.ts @@ -256,6 +256,27 @@ Bun.serve({ new ClientResponse(req, await fs.readFile("artists.ndjson")), "/th_artists.ndjson": async (req) => new ClientResponse(req, await fs.readFile("th_artists.ndjson")), + "/git-pull": async (req) => { + const authFail = requireBasicAuth(req); + if (authFail) return authFail; + + try { + const pull = await $`git pull origin main`.nothrow(); + const output = `${pull.stdout}${pull.stderr}`; + + if (pull.exitCode !== 0) { + return new ClientResponse(req, `Git pull failed: ${output}`, { + status: 500, + }); + } + + return new ClientResponse(req, `Git pull successful: ${output}`); + } catch (err) { + return new ClientResponse(req, `Error during git pull: ${err}`, { + status: 500, + }); + } + }, "/ignore-th/:id": async (req) => { const authFail = requireBasicAuth(req); if (authFail) return authFail; @@ -404,4 +425,4 @@ if (!existsSync("./th_artists.ndjson")) { setInterval(async () => { await runComparison(); -}, 50000); +}, 50000); \ No newline at end of file