mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-10-24 14:20:36 +08:00
In preparation for merging radicle-desktop into radicle-gui. It's a pure rename, so git can follow every file across the move.
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import type { RadiclePeer, SpawnOptions } from "@tests/support/peerManager.js";
|
|
|
|
export async function create(
|
|
peer: RadiclePeer,
|
|
commitLines: string[],
|
|
branch: string,
|
|
changeFn: () => Promise<void>,
|
|
messages: string[],
|
|
options: SpawnOptions,
|
|
): Promise<string> {
|
|
if (branch) {
|
|
await peer.git(["reset", "--hard"], options);
|
|
await peer.git(["switch", "main"], options);
|
|
await peer.git(["switch", "-c", branch], options);
|
|
}
|
|
await changeFn();
|
|
await peer.git(["add", "."], options);
|
|
await peer.git(
|
|
["commit"].concat(...commitLines.map(line => ["-m", line])),
|
|
options,
|
|
);
|
|
const cmd = [
|
|
"push",
|
|
...messages.map(msg => ["-o", `patch.message=${msg}`]).flat(),
|
|
"rad",
|
|
"HEAD:refs/patches",
|
|
];
|
|
const { stderr } = await peer.git(cmd, options);
|
|
const match = stderr.match(/✓ Patch ([a-zA-Z0-9]*) opened/);
|
|
if (!match) {
|
|
throw new Error("Not able to parse patch id");
|
|
}
|
|
return match[1];
|
|
}
|
|
|
|
export async function merge(
|
|
peer: RadiclePeer,
|
|
targetBranch: string,
|
|
featureBranch: string,
|
|
options: SpawnOptions,
|
|
): Promise<void> {
|
|
await peer.git(["switch", targetBranch], options);
|
|
await peer.git(["merge", featureBranch], options);
|
|
await peer.git(["push", "rad", targetBranch], options);
|
|
}
|