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\BugsPlugin; |
15
|
|
|
use ConsoleHelpers\SVNBuddy\Repository\RevisionLog\Plugin\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 |
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
|
|
|
$this->io->writeln('The "<info>' . $project_path . '</info>" project bug tracking expression was reset.'); |
94
|
|
|
} |
95
|
|
|
elseif ( $show_meta ) { |
96
|
|
|
$this->io->writeln( |
97
|
|
|
'Showing project meta information for <info>' . $this->getWorkingCopyUrl() . '</info> url:' |
98
|
|
|
); |
99
|
|
|
|
100
|
|
|
$table = new Table($this->io->getOutput()); |
101
|
|
|
|
102
|
|
|
$table->setHeaders(array('Field Name', 'Field Value')); |
103
|
|
|
|
104
|
|
|
/** @var ProjectsPlugin $projects_plugin */ |
105
|
|
|
$projects_plugin = $this->_revisionLog->getPlugin('projects'); |
106
|
|
|
|
107
|
|
|
foreach ( $projects_plugin->getMeta($project_path) as $field_name => $field_value ) { |
108
|
|
|
$table->addRow(array($field_name, $field_value)); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
$table->render(); |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
} |
116
|
|
|
|