| 8 | const exec = promisify(execFile) |
| 9 | |
| 10 | export async function gitRemote(root: string) { |
| 11 | const origin = path.join(root, "origin.git") |
| 12 | const source = path.join(root, "source") |
| 13 | await git(root, "init", "--bare", origin) |
| 14 | await git(root, "init", source) |
| 15 | await git(source, "config", "user.email", "test@example.com") |
| 16 | await git(source, "config", "user.name", "Test") |
| 17 | await fs.writeFile(path.join(source, "README.md"), "one\n") |
| 18 | await git(source, "add", "README.md") |
| 19 | await git(source, "commit", "-m", "initial") |
| 20 | await git(source, "branch", "-M", "main") |
| 21 | await git(source, "remote", "add", "origin", pathToFileURL(origin).href) |
| 22 | await git(source, "push", "-u", "origin", "main") |
| 23 | await git(root, "--git-dir", origin, "symbolic-ref", "HEAD", "refs/heads/main") |
| 24 | return { |
| 25 | root, |
| 26 | source, |
| 27 | remote: pathToFileURL(origin).href, |
| 28 | reference: { ...Repository.parseRemote("owner/repo"), remote: pathToFileURL(origin).href }, |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | export async function commit(source: string, content: string, message: string) { |
| 33 | await fs.writeFile(path.join(source, "README.md"), content) |