MCPcopy
hub / github.com/desktop/desktop / setupEmptyRepository

Function setupEmptyRepository

app/test/helpers/repositories.ts:35–67  ·  view source on GitHub ↗
(
  t: TestContext,
  defaultBranchName = 'master'
)

Source from the content-addressed store, hash-verified

33 * @returns the new local repository
34 */
35export 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]
55repositoryformatversion = 0
56filemode = true
57bare = false
58logallrefupdates = true
59ignorecase = ${process.platform === 'linux' ? 'true' : 'false'}
60precomposeunicode = 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

Callers 15

createRepositoryFunction · 0.90
createRepositoryFunction · 0.90
createRepositoryFunction · 0.90
createRepositoryFunction · 0.90
git-store-test.tsFile · 0.90
setupRepoFunction · 0.90
setupRepositoriesFunction · 0.90
commit-test.tsFile · 0.90

Calls 1

createTempDirectoryFunction · 0.90

Tested by

no test coverage detected