Skip to content

Commit

Permalink
Merge pull request #49 from initbiz/leave-git-repo
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias-kuendig authored Jan 4, 2021
2 parents f085467 + 82b6682 commit ac3c0fe
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ database:

git:
deployment: gitlab
keepRepo: false # Keep .git in plugins

# deployment: # Automatically configure the Envoy file for GitLab deployments
# user: hostinguser
Expand Down
10 changes: 10 additions & 0 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ public function setOutput(OutputInterface $output)
$this->composer->setOutput($output);
}

public function setWithGitDirectory(bool $withGitDirectory)
{
$this->pluginManager->setWithGitDirectory($withGitDirectory);
$this->themeManager->setWithGitDirectory($withGitDirectory);
}

/**
* Configure the command options.
*
Expand Down Expand Up @@ -206,6 +212,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->write('Migrating database...');
$this->artisan->call('october:up');

if (isset($this->config->git['keepRepo'])) {
$this->setWithGitDirectory($this->config->git['keepRepo']);
}

$themeDeclaration = false;
try {
$themeDeclaration = $this->config->cms['theme'];
Expand Down
18 changes: 18 additions & 0 deletions src/Manager/BaseManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class BaseManager
*/
protected $php;

/**
* @var bool
*/
protected $withGitDirectory = false;

public function __construct()
{
$this->artisan = new Artisan();
Expand All @@ -46,4 +51,17 @@ public function setPhp(string $php = 'php')
$this->php = $php;
$this->artisan->setPhp($php);
}

/**
* Set if remove .git directories or not
*/
public function setWithGitDirectory(bool $withGitDirectory = false)
{
$this->withGitDirectory = $withGitDirectory;
}

public function isWithGitDirectory(): bool
{
return $this->withGitDirectory;
}
}
4 changes: 3 additions & 1 deletion src/Manager/PluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ public function install(string $pluginDeclaration)
throw new RuntimeException('Error while cloning plugin repo: ' . $e->getMessage());
}

$this->removeGitRepo($this->getDirPath($pluginDeclaration));
if(!$this->isWithGitDirectory()) {
$this->removeGitRepo($this->getDirPath($pluginDeclaration));
}
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/Manager/ThemeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ public function install(string $themeDeclaration)
throw new RuntimeException('Error while cloning theme repo: ' . $e->getMessage());
}

$this->removeGitRepo($themeDir);
if(!$this->isWithGitDirectory()) {
$this->removeGitRepo($themeDir);
}

return true;
}
Expand Down
1 change: 1 addition & 0 deletions templates/october.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ git:
excludePlugins: false # Even exclude plugins from your repo. Private plugins will be
# checkout out again during each "install" run. Be careful!
# Manual changes to these plugins will be overwritten.
keepRepo: false # Keep .git in plugins

# deployment:
# user: hostinguser
Expand Down

0 comments on commit ac3c0fe

Please sign in to comment.