Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions packages/host-service/test/helpers/git-fixture.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { mkdtempSync, realpathSync, rmSync, writeFileSync } from "node:fs";
import {
appendFileSync,
mkdtempSync,
realpathSync,
rmSync,
writeFileSync,
} from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import type { SimpleGit } from "simple-git";
Expand Down Expand Up @@ -26,18 +32,20 @@ export async function createGitFixture(): Promise<GitFixture> {
const git = createUserSimpleGit(repoPath);

await git.init(["--initial-branch=main"]);
await git.addConfig("user.email", "test@superset.local");
await git.addConfig("user.name", "Test Runner");
await git.addConfig("commit.gpgsign", "false");
appendFileSync(
join(repoPath, ".git", "config"),
"\n[user]\n\temail = test@superset.local\n\tname = Test Runner\n[commit]\n\tgpgsign = false\n",
);

const commit = async (
message: string,
files: Record<string, string> = { "README.md": message },
): Promise<string> => {
for (const [path, contents] of Object.entries(files)) {
writeFileSync(join(repoPath, path), contents);
await git.add(path);
}
const paths = Object.keys(files);
if (paths.length) await git.raw(["add", "--", ...paths]);
const result = await git.commit(message, undefined, {
"--allow-empty": null,
});
Expand Down
Loading