Test Failed
Pull Request — master (#448)
by
unknown
05:18
created

ReleaseTask   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 28
ccs 0
cts 19
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
A getDescription() 0 4 1
A execute() 0 15 2
1
<?php
2
/*
3
 * This file is part of the Magallanes package.
4
 *
5
 * (c) Andrés Montañez <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Mage\Task\BuiltIn\Deploy;
12
13
use Mage\Task\Exception\ErrorException;
14
use Mage\Task\ExecuteOnRollbackInterface;
15
use Symfony\Component\Process\Process;
16
use Mage\Task\AbstractTask;
17
18
/**
19
 * Release Task - Create the Symlink
20
 *
21
 * @author Andrés Montañez <[email protected]>
22
 */
23
class ReleaseTask extends AbstractTask implements ExecuteOnRollbackInterface
24
{
25
    public function getName()
26
    {
27
        return 'deploy/release';
28
    }
29
30
    public function getDescription()
31
    {
32
        return '[Release] Creating Symlink';
33
    }
34
35
    public function execute()
36
    {
37
        if (!$this->runtime->getEnvOption('releases', false)) {
38
            throw new ErrorException('This task is only available with releases enabled', 40);
39
        }
40
41
        $hostPath = rtrim($this->runtime->getEnvOption('host_path'), '/');
42
        $releaseId = $this->runtime->getReleaseId();
43
44
        $cmdLinkRelease = sprintf('cd %s && ln -snf releases/%s current', $hostPath, $releaseId);
45
46
        /** @var Process $process */
47
        $process = $this->runtime->runRemoteCommand($cmdLinkRelease, false, null);
48
        return $process->isSuccessful();
49
    }
50
}
51