From 90a60632c60fc7e17779679ddf46e08021af8453 Mon Sep 17 00:00:00 2001 From: Vap0r1ze Date: Sun, 25 Aug 2024 19:40:44 -0400 Subject: [PATCH] detect real remote in build step --- scripts/build/common.mjs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/build/common.mjs b/scripts/build/common.mjs index c46a559a7..e797df434 100644 --- a/scripts/build/common.mjs +++ b/scripts/build/common.mjs @@ -193,7 +193,13 @@ export const gitRemotePlugin = { build.onLoad({ filter, namespace: "git-remote" }, async () => { let remote = process.env.VENCORD_REMOTE; if (!remote) { - const res = await promisify(exec)("git remote get-url origin", { encoding: "utf-8" }); + const headRefRes = await promisify(exec)("git symbolic-ref -q HEAD", { encoding: "utf-8" }).catch(() => ({ stdout: "" })); + const headRef = headRefRes.stdout.trim(); + const upstreamRes = await promisify(exec)(`git for-each-ref --format=%(upstream:short) "${headRef}"`, { encoding: "utf-8" }) + .catch(() => ({ stdout: "" })); + const remoteName = upstreamRes.stdout.trim().split("/")[0] || "origin"; + const res = await promisify(exec)(`git remote get-url ${remoteName}`, { encoding: "utf-8" }); + remote = res.stdout.trim() .replace("https://github.com/", "") .replace("git@github.com:", "")