mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-08-20 12:27:29 +08:00
Improve the experience of testing pull requests (#5942)
This commit is contained in:
34
extra/checkout-pr.mjs
Normal file
34
extra/checkout-pr.mjs
Normal file
@@ -0,0 +1,34 @@
|
||||
import childProcess from "child_process";
|
||||
import { parsePrName } from "./kuma-pr/pr-lib.mjs";
|
||||
|
||||
let { name, branch } = parsePrName(process.env.UPTIME_KUMA_GH_REPO);
|
||||
|
||||
console.log(`Checking out PR from ${name}:${branch}`);
|
||||
|
||||
// Checkout the pr
|
||||
let result = childProcess.spawnSync("git", [ "remote", "add", name, `https://github.com/${name}/uptime-kuma` ], {
|
||||
stdio: "inherit"
|
||||
});
|
||||
|
||||
if (result.status !== 0) {
|
||||
console.error("Failed to add remote repository.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
result = childProcess.spawnSync("git", [ "fetch", name, branch ], {
|
||||
stdio: "inherit"
|
||||
});
|
||||
|
||||
if (result.status !== 0) {
|
||||
console.error("Failed to fetch the branch.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
result = childProcess.spawnSync("git", [ "checkout", `${name}/${branch}`, "--force" ], {
|
||||
stdio: "inherit"
|
||||
});
|
||||
|
||||
if (result.status !== 0) {
|
||||
console.error("Failed to checkout the branch.");
|
||||
process.exit(1);
|
||||
}
|
Reference in New Issue
Block a user