From 7a2aca3b9aff20bb7fb16fba4d53e52fef4f9bf0 Mon Sep 17 00:00:00 2001 From: Francesco Abeni Date: Fri, 30 Oct 2015 10:38:10 +0100 Subject: [PATCH] Extend clone options --- RoboFile.dist.ini | 4 +++- RoboFile.php | 27 +++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/RoboFile.dist.ini b/RoboFile.dist.ini index 615510f..4a467da 100644 --- a/RoboFile.dist.ini +++ b/RoboFile.dist.ini @@ -3,4 +3,6 @@ skipClone = false ; If you want to setup your test website in a different folder, you can do that here. ; You can also set an absolute path, i.e. /path/to/my/cms/folder -cmsPath = tests/joomla-cms3 \ No newline at end of file +cmsPath = tests/joomla-cms3 +; If you want to clone a different branch, you can set it here +branch = staging diff --git a/RoboFile.php b/RoboFile.php index 3be30d4..8794976 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -28,7 +28,7 @@ class RoboFile extends \Robo\Tasks */ private function setExecExtension() { - if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') + if ($this->isWindows()) { $this->extension = '.exe'; } @@ -177,7 +177,7 @@ class RoboFile extends \Robo\Tasks // Caching cloned installations locally if (!is_dir('tests/cache') || (time() - filemtime('tests/cache') > 60 * 60 * 24)) { - $this->_exec('git' . $this->extension . ' clone -b staging --single-branch --depth 1 https://github.com/joomla/joomla-cms.git tests/cache'); + $this->_exec($this->buildGitCloneCommand()); } // Get Joomla Clean Testing sites @@ -216,6 +216,29 @@ class RoboFile extends \Robo\Tasks return json_decode(json_encode($configuration)); } + /** + * Build correct git clone command according to local configuration and OS + * + * @return string + */ + private function buildGitCloneCommand() + { + $branch = empty($this->configuration->branch) ? 'staging' : $this->configuration->branch; + $insecure = $this->isWindows() ? ' --insecure' : ''; + + return "git" . $this->extension . " clone -b $branch $insecure --single-branch --depth 1 https://github.com/joomla/joomla-cms.git tests/cache"; + } + + /** + * Check if local OS is Windows + * + * @return bool + */ + private function isWindows() + { + return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'; + } + /** * Get the correct CMS root path *