|
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\Command; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\RevisionLog\Plugin\DatabaseCollectorPlugin\BugsPlugin; |
|
15
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\RevisionLog\Plugin\DatabaseCollectorPlugin\ProjectsPlugin; |
|
16
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\RevisionLog\RevisionLog; |
|
17
|
|
|
use Symfony\Component\Console\Helper\Table; |
|
18
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
19
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
20
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
21
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
22
|
|
|
|
|
23
|
|
|
class ProjectCommand extends AbstractCommand implements IAggregatorAwareCommand |
|
24
|
|
|
{ |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Revision log |
|
28
|
|
|
* |
|
29
|
|
|
* @var RevisionLog |
|
30
|
|
|
*/ |
|
31
|
|
|
private $_revisionLog; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* {@inheritdoc} |
|
35
|
|
|
*/ |
|
36
|
|
|
protected function configure() |
|
37
|
|
|
{ |
|
38
|
|
|
$this |
|
39
|
|
|
->setName('project') |
|
40
|
|
|
->setDescription('Changes and displays project configuration') |
|
41
|
|
|
->addArgument( |
|
42
|
|
|
'path', |
|
43
|
|
|
InputArgument::OPTIONAL, |
|
44
|
|
|
'Working copy path', |
|
45
|
|
|
'.' |
|
46
|
|
|
) |
|
47
|
|
|
->addOption( |
|
48
|
|
|
'refresh-bug-tracking', |
|
49
|
|
|
null, |
|
50
|
|
|
InputOption::VALUE_NONE, |
|
51
|
|
|
'Refreshes value of "bugtraq:logregex" SVN property of the project' |
|
52
|
|
|
) |
|
53
|
|
|
->addOption( |
|
54
|
|
|
'show-meta', |
|
55
|
|
|
null, |
|
56
|
|
|
InputOption::VALUE_NONE, |
|
57
|
|
|
'Shows meta information of a project' |
|
58
|
|
|
); |
|
59
|
|
|
|
|
60
|
|
|
parent::configure(); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* {@inheritdoc} |
|
65
|
|
|
*/ |
|
66
|
|
|
public function initialize(InputInterface $input, OutputInterface $output) |
|
67
|
|
|
{ |
|
68
|
|
|
parent::initialize($input, $output); |
|
69
|
|
|
|
|
70
|
|
|
$this->_revisionLog = $this->getRevisionLog($this->getWorkingCopyUrl()); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* {@inheritdoc} |
|
75
|
|
|
*/ |
|
76
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
77
|
|
|
{ |
|
78
|
|
|
$project_path = $this->_revisionLog->getProjectPath(); |
|
79
|
|
|
$refresh_bug_tracking = $this->io->getOption('refresh-bug-tracking'); |
|
80
|
|
|
$show_meta = $this->io->getOption('show-meta'); |
|
81
|
|
|
|
|
82
|
|
|
if ( !$refresh_bug_tracking && !$show_meta ) { |
|
83
|
|
|
$this->io->writeln('Path in repository: <info>' . $project_path . '</info>'); |
|
84
|
|
|
|
|
85
|
|
|
return; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
if ( $refresh_bug_tracking ) { |
|
89
|
|
|
/** @var BugsPlugin $bugs_plugin */ |
|
90
|
|
|
$bugs_plugin = $this->_revisionLog->getPlugin('bugs'); |
|
91
|
|
|
$bugs_plugin->refreshBugRegExp($project_path); |
|
92
|
|
|
|
|
93
|
|
|
/** @var ProjectsPlugin $projects_plugin */ |
|
94
|
|
|
$projects_plugin = $this->_revisionLog->getPlugin('projects'); |
|
95
|
|
|
$project_meta = $projects_plugin->getMeta($project_path); |
|
96
|
|
|
|
|
97
|
|
|
$this->io->writeln(array( |
|
98
|
|
|
'Changed "<info>' . $project_path . '</info>" project bug tracking expression to', |
|
99
|
|
|
'', |
|
100
|
|
|
'<info>' . $project_meta['BugRegExp'] . '</info>', |
|
101
|
|
|
)); |
|
102
|
|
|
} |
|
103
|
|
|
elseif ( $show_meta ) { |
|
104
|
|
|
$this->io->writeln( |
|
105
|
|
|
'Showing project meta information for <info>' . $this->getWorkingCopyUrl() . '</info> url:' |
|
106
|
|
|
); |
|
107
|
|
|
|
|
108
|
|
|
$table = new Table($this->io->getOutput()); |
|
109
|
|
|
|
|
110
|
|
|
$table->setHeaders(array('Field Name', 'Field Value')); |
|
111
|
|
|
|
|
112
|
|
|
/** @var ProjectsPlugin $projects_plugin */ |
|
113
|
|
|
$projects_plugin = $this->_revisionLog->getPlugin('projects'); |
|
114
|
|
|
|
|
115
|
|
|
foreach ( $projects_plugin->getMeta($project_path) as $field_name => $field_value ) { |
|
116
|
|
|
$table->addRow(array($field_name, $field_value)); |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
$table->render(); |
|
120
|
|
|
} |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
/** |
|
124
|
|
|
* Returns option names, that makes sense to use in aggregation mode. |
|
125
|
|
|
* |
|
126
|
|
|
* @return array |
|
127
|
|
|
*/ |
|
128
|
|
|
public function getAggregatedOptions() |
|
129
|
|
|
{ |
|
130
|
|
|
return array( |
|
131
|
|
|
'refresh-bug-tracking', 'show-meta', |
|
132
|
|
|
); |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
} |
|
136
|
|
|
|