Skip to content

Commit

Permalink
DX-3486: [new] fails for existing git repo (acquia#463)
Browse files Browse the repository at this point in the history
  • Loading branch information
danepowell authored Mar 8, 2021
1 parent bf7070f commit c0fcf54
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Command/NewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ protected function createProject($project, string $dir): void {
* @throws \Exception
*/
protected function initializeGitRepository(string $dir): void {
if ($this->localMachineHelper->getFilesystem()->exists(Path::join($dir, '.git'))) {
$this->logger->debug('.git directory detected, skipping Git repo initialization');
return;
}
$this->localMachineHelper->execute([
'git',
'init',
Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/src/Commands/NewCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function testNewCommand($project, $directory = 'drupal'): void {

$local_machine_helper = $this->mockLocalMachineHelper();

$this->mockGetFilesystem($local_machine_helper);
$this->mockExecuteComposerCreate($this->newProjectDir, $local_machine_helper, $process, $project);
$this->mockExecuteComposerUpdate($local_machine_helper, $this->newProjectDir, $process);
$this->mockExecuteGitInit($local_machine_helper, $this->newProjectDir, $process);
Expand Down

0 comments on commit c0fcf54

Please sign in to comment.