Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,20 @@ export class Git extends EventEmitter implements GitEvents {
* Create a new bare repository `repoName` in the instance repository directory.
* @param repo - the name of the repo
* @param callback - Optionally get a callback `cb(err)` to be notified when the repository was created.
* @param initialBranch - optional name for the initial branch of the repo (instead of using the user's git config)
*/
create(repo: string, callback: (error?: Error) => void) {
create(repo: string, callback: (error?: Error) => void, initialBranch?: string) {
function next(self: Git) {
let ps;
let _error = '';

const dir = self.dirMap(repo);
const gitArgs: string[] = ['init'];

if (self.checkout) {
ps = spawn('git', ['init', dir]);
} else {
ps = spawn('git', ['init', '--bare', dir]);
}
initialBranch && gitArgs.push('-b', initialBranch);
!self.checkout && gitArgs.push('--bare');

ps = spawn('git', [...gitArgs, dir]);

ps.stderr.on('data', function (chunk: string) {
_error += chunk;
Expand Down