1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the SVN-Buddy library. |
4
|
|
|
* For the full copyright and license information, please view |
5
|
|
|
* the LICENSE file that was distributed with this source code. |
6
|
|
|
* |
7
|
|
|
* @copyright Alexander Obuhovich <[email protected]> |
8
|
|
|
* @link https://github.com/console-helpers/svn-buddy |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace ConsoleHelpers\SVNBuddy\Repository\CommitMessage; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\Connector\Connector; |
15
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\RevisionLog\RevisionLogFactory; |
16
|
|
|
|
17
|
|
|
abstract class AbstractMergeTemplate |
18
|
|
|
{ |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Repository connector. |
22
|
|
|
* |
23
|
|
|
* @var Connector |
24
|
|
|
*/ |
25
|
|
|
protected $repositoryConnector; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Revision log factory. |
29
|
|
|
* |
30
|
|
|
* @var RevisionLogFactory |
31
|
|
|
*/ |
32
|
|
|
protected $revisionLogFactory; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Creates commit message builder instance. |
36
|
|
|
* |
37
|
|
|
* @param Connector $repository_connector Repository connector. |
38
|
|
|
* @param RevisionLogFactory $revision_log_factory Revision log factory. |
39
|
|
|
*/ |
40
|
13 |
|
public function __construct( |
41
|
|
|
Connector $repository_connector, |
42
|
|
|
RevisionLogFactory $revision_log_factory |
43
|
|
|
) { |
44
|
13 |
|
$this->repositoryConnector = $repository_connector; |
45
|
13 |
|
$this->revisionLogFactory = $revision_log_factory; |
46
|
13 |
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Returns merge template name. |
50
|
|
|
* |
51
|
|
|
* @return string |
52
|
|
|
*/ |
53
|
|
|
abstract public function getName(); |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Applies merge template to a working copy. |
57
|
|
|
* |
58
|
|
|
* @param string $wc_path Working copy path. |
59
|
|
|
* |
60
|
|
|
* @return string |
61
|
|
|
*/ |
62
|
|
|
abstract public function apply($wc_path); |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Flattens groups in revisions. |
66
|
|
|
* |
67
|
|
|
* @param array $grouped_revisions Grouped revisions. |
68
|
|
|
* |
69
|
|
|
* @return array |
70
|
|
|
*/ |
71
|
6 |
|
protected function flattenMergedRevisions(array $grouped_revisions) |
72
|
|
|
{ |
73
|
6 |
|
if ( count($grouped_revisions) > 1 ) { |
74
|
3 |
|
return \call_user_func_array('array_merge', $grouped_revisions); |
75
|
|
|
} |
76
|
|
|
|
77
|
3 |
|
return \array_values($grouped_revisions); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
} |
81
|
|
|
|