Constant for repo url

This commit is contained in:
2026-09-08 17:41:27 +00:00
parent 6c29a7a0cc
commit 973fd9fa93
3 changed files with 32 additions and 19 deletions
+15 -7
View File
@@ -9,6 +9,7 @@ interface HelperOptions {
branch: string;
from: string;
to: string;
targetRef: string;
parent: number;
restart: boolean;
}
@@ -34,14 +35,25 @@ function parseOptions(args: string[]): HelperOptions {
const branch = values.get("--branch");
const from = values.get("--from");
const to = values.get("--to");
const targetRef = values.get("--target-ref");
const parent = Number(values.get("--parent"));
if (!repo || !branch || !from || !to || !Number.isInteger(parent)) {
if (
!repo ||
!branch ||
!from ||
!to ||
!targetRef ||
!Number.isInteger(parent)
) {
throw new Error("Missing updater helper arguments.");
}
if (!/^[0-9a-f]{40,64}$/u.test(from) || !/^[0-9a-f]{40,64}$/u.test(to)) {
throw new Error("Invalid updater commit identifiers.");
}
return { repo, branch, from, to, parent, restart };
if (targetRef !== `refs/remotes/xo-updater/${branch}`) {
throw new Error("Invalid updater target reference.");
}
return { repo, branch, from, to, targetRef, parent, restart };
}
function run(command: string, args: string[], cwd: string): Promise<void> {
@@ -129,11 +141,7 @@ async function main(): Promise<void> {
const [branch, head, target, status] = await Promise.all([
capture("git", ["branch", "--show-current"], options.repo),
capture("git", ["rev-parse", "HEAD"], options.repo),
capture(
"git",
["rev-parse", `refs/remotes/origin/${options.branch}`],
options.repo,
),
capture("git", ["rev-parse", options.targetRef], options.repo),
capture("git", ["status", "--porcelain"], options.repo),
]);
if (