({
fs,
bare = false,
dir,
gitdir = bare ? dir : join(dir, '.git'),
defaultBranch = 'master',
})
| 24 | * |
| 25 | */ |
| 26 | export async function init({ |
| 27 | fs, |
| 28 | bare = false, |
| 29 | dir, |
| 30 | gitdir = bare ? dir : join(dir, '.git'), |
| 31 | defaultBranch = 'master', |
| 32 | }) { |
| 33 | try { |
| 34 | assertParameter('fs', fs) |
| 35 | assertParameter('gitdir', gitdir) |
| 36 | if (!bare) { |
| 37 | assertParameter('dir', dir) |
| 38 | } |
| 39 | |
| 40 | const fsp = new FileSystem(fs) |
| 41 | const updatedGitdir = await discoverGitdir({ fsp, dotgit: gitdir }) |
| 42 | return await _init({ |
| 43 | fs: fsp, |
| 44 | bare, |
| 45 | dir, |
| 46 | gitdir: updatedGitdir, |
| 47 | defaultBranch, |
| 48 | }) |
| 49 | } catch (err) { |
| 50 | err.caller = 'git.init' |
| 51 | throw err |
| 52 | } |
| 53 | } |
no test coverage detected
searching dependent graphs…