diff --git a/README.md b/README.md index 4eccf47..a7ea7bb 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php index 18207b6..e91dd48 100644 --- a/src/Console/InstallCommand.php +++ b/src/Console/InstallCommand.php @@ -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. * @@ -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']; diff --git a/src/Manager/BaseManager.php b/src/Manager/BaseManager.php index 41b6346..0e796b0 100644 --- a/src/Manager/BaseManager.php +++ b/src/Manager/BaseManager.php @@ -29,6 +29,11 @@ class BaseManager */ protected $php; + /** + * @var bool + */ + protected $withGitDirectory = false; + public function __construct() { $this->artisan = new Artisan(); @@ -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; + } } diff --git a/src/Manager/PluginManager.php b/src/Manager/PluginManager.php index 8f7f285..db9cae7 100644 --- a/src/Manager/PluginManager.php +++ b/src/Manager/PluginManager.php @@ -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)); + } } /** diff --git a/src/Manager/ThemeManager.php b/src/Manager/ThemeManager.php index b6cb067..c0be58c 100644 --- a/src/Manager/ThemeManager.php +++ b/src/Manager/ThemeManager.php @@ -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; } diff --git a/templates/october.yaml b/templates/october.yaml index 42e7aad..0d61384 100644 --- a/templates/october.yaml +++ b/templates/october.yaml @@ -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