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; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
use ConsoleHelpers\ConsoleKit\Config\ConfigEditor; |
15
|
|
|
use ConsoleHelpers\SVNBuddy\Cache\CacheManager; |
16
|
|
|
use ConsoleHelpers\DatabaseMigration\MigrationManager; |
17
|
|
|
use ConsoleHelpers\DatabaseMigration\PhpMigrationRunner; |
18
|
|
|
use ConsoleHelpers\DatabaseMigration\SqlMigrationRunner; |
19
|
|
|
use ConsoleHelpers\SVNBuddy\Config\CommandConfig; |
20
|
|
|
use ConsoleHelpers\SVNBuddy\Database\StatementProfiler; |
21
|
|
|
use ConsoleHelpers\SVNBuddy\Helper\DateHelper; |
22
|
|
|
use ConsoleHelpers\SVNBuddy\Helper\OutputHelper; |
23
|
|
|
use ConsoleHelpers\SVNBuddy\Helper\SizeHelper; |
24
|
|
|
use ConsoleHelpers\SVNBuddy\MergeSourceDetector\ClassicMergeSourceDetector; |
25
|
|
|
use ConsoleHelpers\SVNBuddy\MergeSourceDetector\InPortalMergeSourceDetector; |
26
|
|
|
use ConsoleHelpers\SVNBuddy\MergeSourceDetector\MergeSourceDetectorAggregator; |
27
|
|
|
use ConsoleHelpers\SVNBuddy\Process\ProcessFactory; |
28
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\CommitMessage\CommitMessageBuilder; |
29
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\CommitMessage\EmptyMergeTemplate; |
30
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\CommitMessage\GroupByBugMergeTemplate; |
31
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\CommitMessage\GroupByRevisionMergeTemplate; |
32
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\CommitMessage\MergeTemplateFactory; |
33
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\CommitMessage\SummaryMergeTemplate; |
34
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\Connector\CommandFactory; |
35
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\Connector\Connector; |
36
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\Connector\UrlResolver; |
37
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\Parser\LogMessageParserFactory; |
38
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\Parser\RevisionListParser; |
39
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\RevisionLog\DatabaseManager; |
40
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\RevisionLog\RevisionLogFactory; |
41
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\RevisionLog\RevisionPrinter; |
42
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\WorkingCopyConflictTracker; |
43
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\WorkingCopyResolver; |
44
|
|
|
use ConsoleHelpers\SVNBuddy\Updater\UpdateManager; |
45
|
|
|
use ConsoleHelpers\SVNBuddy\Updater\Updater; |
46
|
|
|
use ConsoleHelpers\SVNBuddy\Updater\VersionUpdateStrategy; |
47
|
|
|
use Symfony\Component\Console\Formatter\OutputFormatterStyle; |
48
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
49
|
|
|
|
50
|
|
|
class Container extends \ConsoleHelpers\ConsoleKit\Container |
51
|
|
|
{ |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* {@inheritdoc} |
55
|
|
|
*/ |
56
|
181 |
|
public function __construct(array $values = array()) |
57
|
|
|
{ |
58
|
181 |
|
parent::__construct($values); |
59
|
|
|
|
60
|
181 |
|
$this['app_name'] = 'SVN-Buddy'; |
61
|
181 |
|
$this['app_version'] = '@git-version@'; |
62
|
|
|
|
63
|
181 |
|
$this['working_directory_sub_folder'] = '.svn-buddy'; |
64
|
|
|
|
65
|
181 |
|
$this['config_defaults'] = array( |
66
|
|
|
'repository-connector.username' => '', |
67
|
|
|
'repository-connector.password' => '', |
68
|
|
|
'repository-connector.last-revision-cache-duration' => '10 minutes', |
69
|
|
|
'update-channel' => 'stable', |
70
|
|
|
); |
71
|
|
|
|
72
|
|
|
$this->extend('output', function ($output) { |
73
|
|
|
/** @var OutputInterface $output */ |
74
|
12 |
|
$output->getFormatter()->setStyle('debug', new OutputFormatterStyle('white', 'magenta')); |
75
|
|
|
|
76
|
12 |
|
return $output; |
77
|
181 |
|
}); |
78
|
|
|
|
79
|
|
|
$this['process_factory'] = function () { |
80
|
10 |
|
return new ProcessFactory(); |
81
|
|
|
}; |
82
|
|
|
|
83
|
|
|
$this['merge_source_detector'] = function () { |
84
|
1 |
|
$merge_source_detector = new MergeSourceDetectorAggregator(0); |
85
|
1 |
|
$merge_source_detector->add(new ClassicMergeSourceDetector(0)); |
86
|
1 |
|
$merge_source_detector->add(new InPortalMergeSourceDetector(50)); |
87
|
|
|
|
88
|
1 |
|
return $merge_source_detector; |
89
|
|
|
}; |
90
|
|
|
|
91
|
|
|
$this['repository_url_resolver'] = function ($c) { |
92
|
1 |
|
return new UrlResolver($c['repository_connector']); |
93
|
|
|
}; |
94
|
|
|
|
95
|
|
|
$this['cache_manager'] = function ($c) { |
96
|
10 |
|
return new CacheManager($c['working_directory'], $c['size_helper'], $c['io']); |
97
|
|
|
}; |
98
|
|
|
|
99
|
|
|
$this['statement_profiler'] = function () { |
100
|
20 |
|
$statement_profiler = new StatementProfiler(); |
101
|
|
|
|
102
|
|
|
// The "AbstractPlugin::getLastRevision" method. |
103
|
20 |
|
$statement_profiler->ignoreDuplicateStatement('SELECT LastRevision FROM PluginData WHERE Name = :name'); |
104
|
|
|
|
105
|
|
|
// The "AbstractPlugin::getProject" method. |
106
|
20 |
|
$statement_profiler->ignoreDuplicateStatement('SELECT Id FROM Projects WHERE Path = :path'); |
107
|
|
|
|
108
|
|
|
// The "AbstractDatabaseCollectorPlugin::getProjects" method. |
109
|
20 |
|
$statement_profiler->ignoreDuplicateStatement( |
110
|
20 |
|
'SELECT Path, Id AS PathId, RevisionAdded, RevisionDeleted, RevisionLastSeen |
111
|
|
|
FROM Paths |
112
|
|
|
WHERE PathHash IN (:path_hashes)' |
113
|
|
|
); |
114
|
|
|
|
115
|
|
|
// The "ProjectsPlugin::createRepositoryWideProject" method. |
116
|
20 |
|
$statement_profiler->ignoreDuplicateStatement( |
117
|
20 |
|
'SELECT Id FROM Paths WHERE ProjectPath = :project_path LIMIT 100' |
118
|
|
|
); |
119
|
|
|
|
120
|
20 |
|
$statement_profiler->setActive(true); |
121
|
20 |
|
$statement_profiler->trackDuplicates(false); |
122
|
|
|
|
123
|
20 |
|
return $statement_profiler; |
124
|
|
|
}; |
125
|
|
|
|
126
|
|
|
$this['project_root_folder'] = function () { |
127
|
152 |
|
return dirname(dirname(__DIR__)); |
128
|
|
|
}; |
129
|
|
|
|
130
|
|
|
$this['migration_manager'] = function ($c) { |
131
|
152 |
|
$migrations_directory = $c['project_root_folder'] . '/migrations'; |
132
|
152 |
|
$migration_manager = new MigrationManager($migrations_directory, $c); |
133
|
152 |
|
$migration_manager->registerMigrationRunner(new SqlMigrationRunner()); |
134
|
152 |
|
$migration_manager->registerMigrationRunner(new PhpMigrationRunner()); |
135
|
|
|
|
136
|
152 |
|
return $migration_manager; |
137
|
|
|
}; |
138
|
|
|
|
139
|
|
|
$this['db_manager'] = function ($c) { |
140
|
2 |
|
return new DatabaseManager($c['working_directory'], $c['migration_manager'], $c['statement_profiler']); |
141
|
|
|
}; |
142
|
|
|
|
143
|
|
|
$this['revision_log_factory'] = function ($c) { |
144
|
2 |
|
return new RevisionLogFactory( |
145
|
2 |
|
$c['repository_connector'], |
146
|
2 |
|
$c['db_manager'], |
147
|
2 |
|
$c['log_message_parser_factory'] |
148
|
|
|
); |
149
|
|
|
}; |
150
|
|
|
|
151
|
|
|
$this['log_message_parser_factory'] = function () { |
152
|
3 |
|
return new LogMessageParserFactory(); |
153
|
|
|
}; |
154
|
|
|
|
155
|
|
|
$this['revision_list_parser'] = function () { |
156
|
9 |
|
return new RevisionListParser(); |
157
|
|
|
}; |
158
|
|
|
|
159
|
|
|
$this['revision_printer'] = function ($c) { |
160
|
1 |
|
return new RevisionPrinter($c['date_helper'], $c['output_helper']); |
161
|
|
|
}; |
162
|
|
|
|
163
|
|
|
$this['command_factory'] = function ($c) { |
164
|
9 |
|
return new CommandFactory($c['config_editor'], $c['process_factory'], $c['io'], $c['cache_manager']); |
165
|
|
|
}; |
166
|
|
|
|
167
|
|
|
$this['repository_connector'] = function ($c) { |
168
|
8 |
|
return new Connector( |
169
|
8 |
|
$c['config_editor'], |
170
|
8 |
|
$c['command_factory'], |
171
|
8 |
|
$c['io'], |
172
|
8 |
|
$c['revision_list_parser'] |
173
|
|
|
); |
174
|
|
|
}; |
175
|
|
|
|
176
|
|
|
$this['commit_message_builder'] = function ($c) { |
177
|
1 |
|
return new CommitMessageBuilder($c['working_copy_conflict_tracker']); |
178
|
|
|
}; |
179
|
|
|
|
180
|
|
|
$this['working_copy_resolver'] = function ($c) { |
181
|
4 |
|
return new WorkingCopyResolver($c['repository_connector']); |
182
|
|
|
}; |
183
|
|
|
|
184
|
|
|
$this['working_copy_conflict_tracker'] = function ($c) { |
185
|
2 |
|
return new WorkingCopyConflictTracker($c['repository_connector'], $c['command_config']); |
186
|
|
|
}; |
187
|
|
|
|
188
|
|
|
$this['merge_template_factory'] = function ($c) { |
189
|
1 |
|
$factory = new MergeTemplateFactory(); |
190
|
1 |
|
$repository_connector = $c['repository_connector']; |
191
|
1 |
|
$revision_log_factory = $c['revision_log_factory']; |
192
|
|
|
|
193
|
1 |
|
$factory->add(new GroupByBugMergeTemplate($repository_connector, $revision_log_factory)); |
194
|
1 |
|
$factory->add(new GroupByRevisionMergeTemplate($repository_connector, $revision_log_factory)); |
195
|
1 |
|
$factory->add(new SummaryMergeTemplate($repository_connector, $revision_log_factory)); |
196
|
1 |
|
$factory->add(new EmptyMergeTemplate($repository_connector, $revision_log_factory)); |
197
|
|
|
|
198
|
1 |
|
return $factory; |
199
|
|
|
}; |
200
|
|
|
|
201
|
|
|
$this['command_config'] = function ($c) { |
202
|
3 |
|
return new CommandConfig($c['config_editor'], $c['working_copy_resolver']); |
203
|
|
|
}; |
204
|
|
|
|
205
|
|
|
$this['date_helper'] = function () { |
206
|
2 |
|
return new DateHelper(); |
207
|
|
|
}; |
208
|
|
|
|
209
|
|
|
$this['size_helper'] = function () { |
210
|
11 |
|
return new SizeHelper(); |
211
|
|
|
}; |
212
|
|
|
|
213
|
|
|
$this['output_helper'] = function () { |
214
|
2 |
|
return new OutputHelper(); |
215
|
|
|
}; |
216
|
|
|
|
217
|
|
|
$this['editor'] = function () { |
218
|
1 |
|
return new InteractiveEditor(); |
219
|
|
|
}; |
220
|
|
|
|
221
|
|
|
$this['updater'] = function ($c) { |
222
|
|
|
/** @var ConfigEditor $config_editor */ |
223
|
|
|
$config_editor = $c['config_editor']; |
224
|
|
|
|
225
|
|
|
$update_strategy = new VersionUpdateStrategy(); |
226
|
|
|
$update_strategy->setStability($config_editor->get('update-channel')); |
|
|
|
|
227
|
|
|
$update_strategy->setCurrentLocalVersion($c['app_version']); |
228
|
|
|
|
229
|
|
|
$updater = new Updater(null, false); |
230
|
|
|
$updater->setStrategyObject($update_strategy); |
231
|
|
|
|
232
|
|
|
return $updater; |
233
|
|
|
}; |
234
|
|
|
|
235
|
|
|
$this['update_manager'] = function ($c) { |
236
|
|
|
return new UpdateManager( |
237
|
|
|
$c['updater'], |
238
|
|
|
$c['config_editor'], |
239
|
|
|
$c['process_factory'], |
240
|
|
|
$c['working_directory'] |
241
|
|
|
); |
242
|
|
|
}; |
243
|
181 |
|
} |
244
|
|
|
|
245
|
|
|
} |
246
|
|
|
|