|
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 |
|
|
|
|
|
|
23
|
|
|
repository (' . ($this->mu()->getVendorName() ?: 'Vendor Name') . '/' . ($this->mu()->getPackageName() ?: 'Package Name') . ') |
|
|
|
|
|
|
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
|
|
|
|