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 FinaliseUpgradeWithMergeIntoMaster extends Task |
11
|
|
|
{ |
12
|
|
|
protected $taskStep = 's70'; |
13
|
|
|
|
14
|
|
|
public function getTitle() |
15
|
|
|
{ |
16
|
|
|
if ($this->mu()->getRunIrreversibly()) { |
|
|
|
|
17
|
|
|
return 'Finalise Upgrade with merge into Master.'; |
18
|
|
|
} |
19
|
|
|
return 'Finalise Upgrade with merge into Master (TURNED OFF)'; |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
public function getDescription() |
23
|
|
|
{ |
24
|
|
|
if ($this->mu()->getRunIrreversibly()) { |
25
|
|
|
return ' |
26
|
|
|
CAREFUL - THIS STEP CAN NOT BE UNDONE. IT IS NOT RECOMMENDED! |
27
|
|
|
You should only run this upgrade task if you are 100% sure. |
28
|
|
|
You can turn off this task by setting `runIrreversibly` to false in the upgrader. |
29
|
|
|
You can do this as follows: `$upgrader->setRunIrreversibly(false)` |
30
|
|
|
'; |
31
|
|
|
} |
32
|
|
|
return ' |
33
|
|
|
This is currently turned off allowing you to run the upgrader more than once without any consequences to the project at hand. |
34
|
|
|
You can turn on this task by setting `runIrreversibly` to true in the upgrader. |
35
|
|
|
You can do this as follows: `$upgrader->setRunIrreversibly(true)`.'; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function runActualTask($params = []) |
39
|
|
|
{ |
40
|
|
|
$branchName = $this->mu()->getNameOfTempBranch(); |
|
|
|
|
41
|
|
|
if ($this->mu()->getRunIrreversibly()) { |
42
|
|
|
$this->mu()->execMe( |
43
|
|
|
$this->mu()->getGitRootDir(), |
44
|
|
|
' |
45
|
|
|
git checkout ' . $branchName . ' |
46
|
|
|
git pull origin ' . $branchName . ' |
47
|
|
|
git checkout master |
48
|
|
|
git merge --squash ' . $branchName . ' |
49
|
|
|
git commit . -m "MAJOR: upgrade to Silverstripe 4" |
50
|
|
|
git push origin master |
51
|
|
|
git branch -D ' . $branchName . ' |
52
|
|
|
git push origin --delete ' . $branchName . ' |
53
|
|
|
', |
54
|
|
|
'merging ' . $branchName . ' into master in ' . $this->mu()->getGitRootDir(), |
55
|
|
|
false |
56
|
|
|
); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
protected function hasCommitAndPush() |
61
|
|
|
{ |
62
|
|
|
return false; |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|