Add git, gh, openssh-client, curl, and sudo to the computer image with a docker smoke test. Mount deployment-owner project workspacePath at /home/rakazo/project, align /home/rakazo file paths with shell, and resolve default branch from origin/HEAD. Inject the owner GitHub token from encrypted deployment settings only into project computers; enforce branch-only push, block force-push, and require approval before the first push or gh pr in a run. Add runaway guards (tool fuse and stall pause), collapse live narration, fix streaming progress merge, DE run strings, and Lead as the project main Oo name. Fix evo-deploy test flake. Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>
71 lines
2.2 KiB
TypeScript
71 lines
2.2 KiB
TypeScript
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import path from "node:path";
|
|
import { afterEach, describe, expect, it } from "vitest";
|
|
import { type GitRunner, readGitCheckout } from "./git-checkout.js";
|
|
|
|
describe("readGitCheckout", () => {
|
|
const roots: string[] = [];
|
|
|
|
afterEach(() => {
|
|
for (const root of roots.splice(0)) {
|
|
rmSync(root, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
function tempDir(prefix: string) {
|
|
const root = mkdtempSync(path.join(tmpdir(), prefix));
|
|
roots.push(root);
|
|
return root;
|
|
}
|
|
|
|
it("returns absent status when .git is missing", async () => {
|
|
const root = tempDir("git-checkout-absent-");
|
|
await expect(readGitCheckout(root)).resolves.toEqual({
|
|
present: false,
|
|
remoteUrl: null,
|
|
defaultBranch: null,
|
|
headCommit: null,
|
|
dirty: false,
|
|
dirtyPaths: [],
|
|
});
|
|
});
|
|
|
|
it("reads remote, branch, commit, and dirty paths from git metadata", async () => {
|
|
const root = tempDir("git-checkout-present-");
|
|
mkdirSync(path.join(root, ".git"));
|
|
writeFileSync(path.join(root, "README.md"), "hello");
|
|
|
|
const runner: GitRunner = async (args) => {
|
|
if (args.join(" ") === "rev-parse HEAD") {
|
|
return { ok: true, output: "abc123def456\n" };
|
|
}
|
|
if (args.join(" ") === "rev-parse --abbrev-ref HEAD") {
|
|
return { ok: true, output: "feature/login\n" };
|
|
}
|
|
if (args.join(" ") === "symbolic-ref --short refs/remotes/origin/HEAD") {
|
|
return { ok: true, output: "origin/main\n" };
|
|
}
|
|
if (args.join(" ") === "remote get-url origin") {
|
|
return { ok: true, output: "https://github.com/example/demo.git\n" };
|
|
}
|
|
if (args.includes("status")) {
|
|
return { ok: true, output: " M README.md\n" };
|
|
}
|
|
if (args.includes("ls-files")) {
|
|
return { ok: true, output: "notes.txt\n" };
|
|
}
|
|
return { ok: false, output: "" };
|
|
};
|
|
|
|
await expect(readGitCheckout(root, runner)).resolves.toEqual({
|
|
present: true,
|
|
remoteUrl: "https://github.com/example/demo.git",
|
|
defaultBranch: "main",
|
|
headCommit: "abc123def456",
|
|
dirty: true,
|
|
dirtyPaths: ["README.md", "notes.txt"],
|
|
});
|
|
});
|
|
});
|