Passed
Branch master (2f7647)
by Nicolaas
04:56 queued 03:20
created

AddUpgradeBranch::getTitle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Sunnysideup\UpgradeToSilverstripe4\Tasks\IndividualTasks;
4
5
use Sunnysideup\UpgradeToSilverstripe4\Tasks\Task;
6
7
/**
8
 * Adds a new branch to your repository that is going to be used for upgrading it.
9
 */
10
class AddUpgradeBranch extends Task
11
{
12
    protected $taskStep = 's10';
13
14
    public function getTitle()
15
    {
16
        return 'Add Upgrade Branch';
17
    }
18
19
    public function getDescription()
20
    {
21
        return '
22
            Adds a new branch (' . $this->mu()->getNameOfTempBranch() . ') to your
0 ignored issues
show
Bug introduced by
The method getNameOfTempBranch() does not exist on Sunnysideup\UpgradeToSilverstripe4\ModuleUpgrader. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

22
            Adds a new branch (' . $this->mu()->/** @scrutinizer ignore-call */ getNameOfTempBranch() . ') to your
Loading history...
23
            repository (' . ($this->mu()->getVendorName() ?: 'Vendor Name') . '/' . ($this->mu()->getPackageName() ?: 'Package Name') . ')
0 ignored issues
show
Bug introduced by
The method getVendorName() does not exist on Sunnysideup\UpgradeToSilverstripe4\ModuleUpgrader. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
            repository (' . ($this->mu()->/** @scrutinizer ignore-call */ getVendorName() ?: 'Vendor Name') . '/' . ($this->mu()->getPackageName() ?: 'Package Name') . ')
Loading history...
Bug introduced by
The method getPackageName() does not exist on Sunnysideup\UpgradeToSilverstripe4\ModuleUpgrader. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
            repository (' . ($this->mu()->getVendorName() ?: 'Vendor Name') . '/' . ($this->mu()->/** @scrutinizer ignore-call */ getPackageName() ?: 'Package Name') . ')
Loading history...
24
            that is going to be used for upgrading it.
25
            If it exists then it will be DELETED!';
26
    }
27
28
    public function runActualTask($params = [])
29
    {
30
        $this->mu()->execMe(
31
            $this->mu()->getGitRootDir(),
32
            'if git show-ref --quiet refs/heads/' . $this->mu()->getNameOfTempBranch() . '; then git branch -d ' . $this->mu()->getNameOfTempBranch() . '; git push origin --delete ' . $this->mu()->getNameOfTempBranch() . '; fi',
33
            'delete upgrade branch (' . $this->mu()->getNameOfTempBranch() . ') locally',
34
            false
35
        );
36
37
        $this->mu()->execMe(
38
            $this->mu()->getGitRootDir(),
39
            'git push origin --delete ' . $this->mu()->getNameOfTempBranch(),
40
            'delete upgrade branch (' . $this->mu()->getNameOfTempBranch() . ') remotely',
41
            false
42
        );
43
44
        $this->mu()->execMe(
45
            $this->mu()->getGitRootDir(),
46
            'git checkout -b ' . $this->mu()->getNameOfTempBranch(),
47
            'create and checkout new branch: ' . $this->mu()->getNameOfTempBranch(),
48
            false
49
        );
50
    }
51
52
    protected function hasCommitAndPush()
53
    {
54
        return false;
55
    }
56
}
57