From cc12c5f17763588b0ec11e7bf96889def775396d Mon Sep 17 00:00:00 2001 From: "Martin Studer, fluxlabs ag" Date: Thu, 31 Mar 2022 23:08:28 -0400 Subject: [PATCH] fix commands --- CHANGELOG.md | 3 +++ composer.json | 2 +- .../DownloadHandlers/GitCloneCommandHandler.php | 5 ++--- .../DownloadHandlers/GitCloneStateCommandHandler.php | 7 +++---- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ecf417..8511f67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # CHANGELOG +## [1.0.6] +- fix: git - commands + ## [1.0.5] - fix: git - delete directory if exists diff --git a/composer.json b/composer.json index 82a8238..ba46d1f 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "flux-eco/source-downloader", "description": "Component for flux-capacitor apps developed by fluxlabs", - "version": "1.0.5", + "version": "1.0.6", "type": "flux-eco", "keywords": [ "flux-eco", diff --git a/src/Core/Application/DownloadHandlers/GitCloneCommandHandler.php b/src/Core/Application/DownloadHandlers/GitCloneCommandHandler.php index 722b6e8..93e322f 100644 --- a/src/Core/Application/DownloadHandlers/GitCloneCommandHandler.php +++ b/src/Core/Application/DownloadHandlers/GitCloneCommandHandler.php @@ -32,11 +32,10 @@ public function handle(Command $command) : void return; } - $deleteDirectory = ''; + $createDirectory = 'mkdir -p ' . $command->getDirectoryPath(); if(is_dir($command->getDirectoryPath())) { - $deleteDirectory = 'rm -r ' . $command->getDirectoryPath(); + $createDirectory = 'rm -r ' . $command->getDirectoryPath().' && '.$createDirectory; } - $createDirectory = $deleteDirectory .' && mkdir -p ' . $command->getDirectoryPath(); $cdDirectory = 'cd ' . $command->getDirectoryPath(); $cloneRepository = 'git clone --branch ' . $command->getTag() . ' ' . $command->getUrl() . ' ' . $command->getDirectoryName(); diff --git a/src/Core/Application/DownloadHandlers/GitCloneStateCommandHandler.php b/src/Core/Application/DownloadHandlers/GitCloneStateCommandHandler.php index efa0df4..85f44a9 100644 --- a/src/Core/Application/DownloadHandlers/GitCloneStateCommandHandler.php +++ b/src/Core/Application/DownloadHandlers/GitCloneStateCommandHandler.php @@ -32,14 +32,13 @@ public function handle(Command $command) : void return; } - $deleteDirectory = ''; + $createDirectory = 'mkdir -p ' . $command->getDirectoryPath(); if(is_dir($command->getDirectoryPath())) { - $deleteDirectory = 'rm -r ' . $command->getDirectoryPath(); + $createDirectory = 'rm -r ' . $command->getDirectoryPath().' && '.$createDirectory; } - $createDirectory = $deleteDirectory .' && mkdir -p ' . $command->getDirectoryPath(); $cdDirectory = 'cd ' . $command->getDirectoryPath(); $cloneRepository = 'git clone --depth 1 --branch '.$command->getTag() .' '. $command->getUrl().' '.$command->getDirectoryName(); - $this->shellExecutorClient->execute([$deleteDirectory, $createDirectory, $cdDirectory, $cloneRepository]); + $this->shellExecutorClient->execute([$createDirectory, $cdDirectory, $cloneRepository]); } } \ No newline at end of file