From 840b7e38ab73b0dcfe270f032fd40e564e47b02d Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Thu, 15 Mar 2018 21:58:21 +0000 Subject: [PATCH 1/2] Install tagged versions with box and composer install (if available) --- tools.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools.php b/tools.php index 3faa0546..89d524ff 100644 --- a/tools.php +++ b/tools.php @@ -169,7 +169,7 @@ public static function import(array $command): Command public function __toString(): string { return sprintf( - 'cd $HOME && git clone %s && cd $HOME/%s && composer install --no-dev --no-suggest --prefer-dist -n && box build && mv %s %s && chmod +x %s && cd && rm -rf $HOME/%s', + 'cd $HOME && git clone %s && cd $HOME/%s && git checkout $(git describe --tags $(git rev-list --tags --max-count=1)) && composer install --no-dev --no-suggest --prefer-dist -n && box build && mv %s %s && chmod +x %s && cd && rm -rf $HOME/%s', $this->repository, $this->getTargetDir(), $this->phar, @@ -204,7 +204,7 @@ public static function import(array $command): Command public function __toString(): string { return sprintf( - 'cd $HOME && git clone %s && cd $HOME/%s && composer install --no-dev --no-suggest --prefer-dist -n', + 'cd $HOME && git clone %s && cd $HOME/%s && git checkout $(git describe --tags $(git rev-list --tags --max-count=1) 2>/dev/null) && composer install --no-dev --no-suggest --prefer-dist -n', $this->repository, $this->getTargetDir() ); From 5d49e78b4b1e5b6fb6028de3d1052af77f4b8aba Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Thu, 15 Mar 2018 22:23:37 +0000 Subject: [PATCH 2/2] Allow version configuration in box and composer installs to be able to force versions that build Use the latest commit of the EasyCodingStandard as the latest tagged version does not build cleanly. --- tools.json | 3 ++- tools.php | 20 +++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/tools.json b/tools.json index dc7e0e0c..b641278d 100644 --- a/tools.json +++ b/tools.json @@ -177,7 +177,8 @@ "box-build": { "repository": "https://github.com/mmoreram/php-formatter.git", "phar": "build/php-formatter.phar", - "bin": "/usr/local/bin/php-formatter" + "bin": "/usr/local/bin/php-formatter", + "version": "1fa3d9a3e1c67654f3fe2511bd28fa7c33b59d7e" } }, "test": "php-formatter list" diff --git a/tools.php b/tools.php index 89d524ff..5178c4c8 100644 --- a/tools.php +++ b/tools.php @@ -151,27 +151,30 @@ final class BoxBuildCommand implements Command private $repository; private $phar; private $bin; + private $version; - private function __construct(string $repository, string $phar, string $bin) + private function __construct(string $repository, string $phar, string $bin, ?string $version = null) { $this->repository = $repository; $this->phar = $phar; $this->bin = $bin; + $this->version = $version; } public static function import(array $command): Command { \Assert\requireFields(['repository', 'phar', 'bin'], $command, 'BoxBuildCommand'); - return new self($command['repository'], $command['phar'], $command['bin']); + return new self($command['repository'], $command['phar'], $command['bin'], $command['version'] ?? null); } public function __toString(): string { return sprintf( - 'cd $HOME && git clone %s && cd $HOME/%s && git checkout $(git describe --tags $(git rev-list --tags --max-count=1)) && composer install --no-dev --no-suggest --prefer-dist -n && box build && mv %s %s && chmod +x %s && cd && rm -rf $HOME/%s', + 'cd $HOME && git clone %s && cd $HOME/%s && git checkout %s && composer install --no-dev --no-suggest --prefer-dist -n && box build && mv %s %s && chmod +x %s && cd && rm -rf $HOME/%s', $this->repository, $this->getTargetDir(), + $this->version ?? '$(git describe --tags $(git rev-list --tags --max-count=1) 2>/dev/null)', $this->phar, $this->bin, $this->bin, @@ -188,25 +191,28 @@ private function getTargetDir(): string final class ComposerInstallCommand implements Command { private $repository; + private $version; - public function __construct(string $repository) + public function __construct(string $repository, ?string $version = null) { $this->repository = $repository; + $this->version = $version; } public static function import(array $command): Command { \Assert\requireFields(['repository'], $command, 'ComposerInstallCommand'); - return new self($command['repository']); + return new self($command['repository'], $command['version'] ?? null); } public function __toString(): string { return sprintf( - 'cd $HOME && git clone %s && cd $HOME/%s && git checkout $(git describe --tags $(git rev-list --tags --max-count=1) 2>/dev/null) && composer install --no-dev --no-suggest --prefer-dist -n', + 'cd $HOME && git clone %s && cd $HOME/%s && git checkout %s && composer install --no-dev --no-suggest --prefer-dist -n', $this->repository, - $this->getTargetDir() + $this->getTargetDir(), + $this->version ?? '$(git describe --tags $(git rev-list --tags --max-count=1) 2>/dev/null)' ); }