Skip to content
Merged
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
9 changes: 7 additions & 2 deletions src/NewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ protected function configure()
->addArgument('name', InputArgument::REQUIRED)
->addOption('dev', null, InputOption::VALUE_NONE, 'Installs the latest "development" release')
->addOption('git', null, InputOption::VALUE_NONE, 'Initialize a Git repository')
->addOption('branch', null, InputOption::VALUE_REQUIRED, 'Set your branch name, defaults to "main"')
->addOption('github', null, InputOption::VALUE_OPTIONAL, 'Create a new repository on GitHub', false)
->addOption('organization', null, InputOption::VALUE_REQUIRED, 'The GitHub organization to create the new repository for')
->addOption('jet', null, InputOption::VALUE_NONE, 'Installs the Laravel Jetstream scaffolding')
Expand Down Expand Up @@ -207,8 +208,10 @@ protected function createRepository(string $directory, InputInterface $input, Ou
{
chdir($directory);

$branch = $input->getOption('branch') ?: 'main';

$commands = [
'git init -q -b main .',
"git init -q -b $branch .",
'git add .',
'git commit -q -m "Set up a fresh Laravel app"',
];
Expand Down Expand Up @@ -267,9 +270,11 @@ protected function pushToGitHub(string $name, string $directory, InputInterface

$flags = $input->getOption('github') ?: '--private';

$branch = $input->getOption('branch') ?: 'main';

$commands = [
"gh repo create $name -y $flags",
"git -c credential.helper= -c credential.helper='!gh auth git-credential' push -q -u origin main",
"git -c credential.helper= -c credential.helper='!gh auth git-credential' push -q -u origin $branch",
];

$this->runCommands($commands, $input, $output, ['GIT_TERMINAL_PROMPT' => 0]);
Expand Down