( t: TestContext, defaultBranchName = 'master' )
| 33 | * @returns the new local repository |
| 34 | */ |
| 35 | export async function setupEmptyRepository( |
| 36 | t: TestContext, |
| 37 | defaultBranchName = 'master' |
| 38 | ): Promise<Repository> { |
| 39 | const repoPath = await createTempDirectory(t) |
| 40 | |
| 41 | await mkdir(join(repoPath, '.git')) |
| 42 | await mkdir(join(repoPath, '.git/objects')) |
| 43 | await mkdir(join(repoPath, '.git/refs')) |
| 44 | await mkdir(join(repoPath, '.git/refs/tags')) |
| 45 | await mkdir(join(repoPath, '.git/refs/heads')) |
| 46 | await mkdir(join(repoPath, '.git/info')) |
| 47 | |
| 48 | const headRef = `ref: refs/heads/${defaultBranchName}\n` |
| 49 | |
| 50 | await Promise.all([ |
| 51 | writeFile(join(repoPath, '.git/HEAD'), headRef), |
| 52 | writeFile( |
| 53 | join(repoPath, '.git/config'), |
| 54 | `[core] |
| 55 | repositoryformatversion = 0 |
| 56 | filemode = true |
| 57 | bare = false |
| 58 | logallrefupdates = true |
| 59 | ignorecase = ${process.platform === 'linux' ? 'true' : 'false'} |
| 60 | precomposeunicode = true |
| 61 | ` |
| 62 | ), |
| 63 | writeFile(join(repoPath, '.git/description'), DefaultGitDescription), |
| 64 | ]) |
| 65 | |
| 66 | return new Repository(repoPath, -1, null, false) |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Initializes a new, empty, git repository at in a temporary location with |
no test coverage detected