(
simpleGit: SimpleGitFactory,
opt: {
baseDir: string;
config?: GitConfig;
baseBranch?: string;
},
)
| 11 | export type GitConfig = { name: string; email: string }; |
| 12 | |
| 13 | export async function initGitRepo( |
| 14 | simpleGit: SimpleGitFactory, |
| 15 | opt: { |
| 16 | baseDir: string; |
| 17 | config?: GitConfig; |
| 18 | baseBranch?: string; |
| 19 | }, |
| 20 | ): Promise<SimpleGit> { |
| 21 | const { baseDir, baseBranch } = opt; |
| 22 | await mkdir(baseDir, { recursive: true }); |
| 23 | const git = simpleGit(baseDir); |
| 24 | await git.init(); |
| 25 | await git.branch(['-M', baseBranch ?? 'main']); |
| 26 | await configureGitUser(git, opt.config); |
| 27 | return git; |
| 28 | } |
| 29 | |
| 30 | /** Like {@link initGitRepo}, but with a simulated remote origin. Working directory is `<baseDir>/repo`. */ |
| 31 | export async function initGitRepoWithRemote( |
no test coverage detected