1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace Dontdrinkandroot\Gitki\WebBundle\Command; |
5
|
|
|
|
6
|
|
|
use GitWrapper\GitWrapper; |
7
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
8
|
|
|
use Symfony\Component\Console\Input\ArrayInput; |
9
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
10
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
11
|
|
|
use Symfony\Component\Console\Question\ConfirmationQuestion; |
12
|
|
|
use Symfony\Component\Filesystem\Filesystem; |
13
|
|
|
|
14
|
|
|
class LoadFixturesCommand extends ContainerAwareCommand |
15
|
|
|
{ |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* {@inheritdoc} |
19
|
|
|
*/ |
20
|
|
|
protected function configure() |
21
|
|
|
{ |
22
|
|
|
$this |
23
|
|
|
->setName('gitki:fixtures:load') |
24
|
|
|
->setDescription('Load fixtures as they are used in the tests'); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* {@inheritdoc} |
29
|
|
|
*/ |
30
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
31
|
|
|
{ |
32
|
|
|
$doctrineFixturesCommand = $this->getApplication()->find('doctrine:fixtures:load'); |
33
|
|
|
$doctrineFixturesCommand->run(new ArrayInput([]), $output); |
34
|
|
|
|
35
|
|
|
$questionHelper = $this->getHelper('question'); |
36
|
|
|
$question = new ConfirmationQuestion('Overwrite repository?', false); |
37
|
|
|
if (!$questionHelper->ask($input, $output, $question)) { |
38
|
|
|
return; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
$repositoryPath = $this->getContainer()->getParameter('repository_path'); |
42
|
|
|
$testRepoPath = realPath(__DIR__ . '/../../../var/data/test/repo/'); |
43
|
|
|
|
44
|
|
|
$fileSystem = new Filesystem(); |
45
|
|
|
$fileSystem->remove($repositoryPath); |
46
|
|
|
|
47
|
|
|
$fileSystem->remove($repositoryPath); |
48
|
|
|
|
49
|
|
|
$fileSystem->mkdir($repositoryPath); |
50
|
|
|
$fileSystem->mirror($testRepoPath, $repositoryPath); |
51
|
|
|
|
52
|
|
|
$git = new GitWrapper(); |
53
|
|
|
$workingCopy = $git->init($repositoryPath); |
54
|
|
|
$workingCopy->add('', ['A' => '']); |
55
|
|
|
$workingCopy->commit('Initial commit'); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|