diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c12bac3..7e7c407b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Added - Added `testLocally` function (analog `test` fn) +- Added `ConfigurationException` ### Changed - Server config `setPty` renamed to `pty` [#953](https://github.com/deployphp/deployer/pull/953) @@ -12,6 +13,7 @@ - `deploy:unlock` now always successful [#950](https://github.com/deployphp/deployer/pull/950) - Added option `-L` to `setfacl` [#956](https://github.com/deployphp/deployer/pull/956) - Run `deploy:unlock` when deploy is fail [#958](https://github.com/deployphp/deployer/pull/958) +- Now throw exception on duplicates in `shared_dirs` ### Fixed - Fixed native ssh scp option diff --git a/recipe/deploy/shared.php b/recipe/deploy/shared.php index 0bec4bc8..c194dd13 100644 --- a/recipe/deploy/shared.php +++ b/recipe/deploy/shared.php @@ -7,10 +7,21 @@ namespace Deployer; +use Deployer\Exception\ConfigurationException; + desc('Creating symlinks for shared files and dirs'); task('deploy:shared', function () { $sharedPath = "{{deploy_path}}/shared"; + // Validate shared_dir, find duplicates + foreach (get('shared_dirs') as $a) { + foreach (get('shared_dirs') as $b) { + if ($a !== $b && strpos($a, $b) === 0) { + throw new ConfigurationException("Can not share same dirs `$a` and `$b`."); + } + } + } + foreach (get('shared_dirs') as $dir) { // Check if shared dir does not exists. if (!test("[ -d $sharedPath/$dir ]")) { diff --git a/src/Exception/ConfigurationException.php b/src/Exception/ConfigurationException.php new file mode 100644 index 00000000..82c865fe --- /dev/null +++ b/src/Exception/ConfigurationException.php @@ -0,0 +1,12 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Deployer\Exception; + +class ConfigurationException extends \RuntimeException +{ +}