Completed
Push — master ( bfa4e7...fe778b )
by Alexander
02:35
created

UpdateCommand::prepareDependencies()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 0
cts 5
cp 0
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
crap 2
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\WorkingCopyConflictTracker;
15
use Symfony\Component\Console\Input\InputArgument;
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Output\OutputInterface;
18
19
class UpdateCommand extends AbstractCommand implements IAggregatorAwareCommand
20
{
21
22
	/**
23
	 * Working copy conflict tracker.
24
	 *
25
	 * @var WorkingCopyConflictTracker
26
	 */
27
	private $_workingCopyConflictTracker;
28
29
	/**
30
	 * Prepare dependencies.
31
	 *
32
	 * @return void
33
	 */
34
	protected function prepareDependencies()
35
	{
36
		parent::prepareDependencies();
37
38
		$container = $this->getContainer();
39
40
		$this->_workingCopyConflictTracker = $container['working_copy_conflict_tracker'];
41
	}
42
43
	/**
44
	 * {@inheritdoc}
45
	 */
46
	protected function configure()
47
	{
48
		$this
49
			->setName('update')
50
			->setDescription('Bring changes from the repository into the working copy')
51
			->setAliases(array('up'))
52
			->addArgument(
53
				'path',
54
				InputArgument::OPTIONAL,
55
				'Working copy path',
56
				'.'
57
			);
58
59
		parent::configure();
60
	}
61
62
	/**
63
	 * {@inheritdoc}
64
	 */
65
	protected function execute(InputInterface $input, OutputInterface $output)
66
	{
67
		$wc_path = $this->getWorkingCopyPath();
68
69
		$this->io->writeln('Updating working copy ... ');
70
		$command = $this->repositoryConnector->getCommand('update', '{' . $wc_path . '}');
71
		$command->runLive(array(
72
			$wc_path => '.',
73
		));
74
75
		if ( $this->_workingCopyConflictTracker->getNewConflicts($wc_path) ) {
76
			$this->_workingCopyConflictTracker->add($wc_path);
77
		}
78
79
		$this->io->writeln('<info>Done</info>');
80
	}
81
82
}
83