mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-02-23 15:05:11 +00:00
detect real remote in build step
This commit is contained in:
parent
561cdb26b4
commit
90a60632c6
1 changed files with 7 additions and 1 deletions
|
@ -193,7 +193,13 @@ export const gitRemotePlugin = {
|
||||||
build.onLoad({ filter, namespace: "git-remote" }, async () => {
|
build.onLoad({ filter, namespace: "git-remote" }, async () => {
|
||||||
let remote = process.env.VENCORD_REMOTE;
|
let remote = process.env.VENCORD_REMOTE;
|
||||||
if (!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()
|
remote = res.stdout.trim()
|
||||||
.replace("https://github.com/", "")
|
.replace("https://github.com/", "")
|
||||||
.replace("git@github.com:", "")
|
.replace("git@github.com:", "")
|
||||||
|
|
Loading…
Add table
Reference in a new issue