Skip to content

Commit f0be363

Browse files
committed
Add command to re-import all projects (Case 162267)
1 parent c116ff0 commit f0be363

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
namespace AppBundle\Command;
4+
5+
use AppBundle\Entity\Repository\ProjectRepository;
6+
use AppBundle\ProjectImport\ImportProjectTask;
7+
use Symfony\Component\Console\Command\Command;
8+
use Symfony\Component\Console\Input\InputArgument;
9+
use Symfony\Component\Console\Input\InputInterface;
10+
use Symfony\Component\Console\Output\OutputInterface;
11+
12+
class ReimportAllProjectsCommand extends Command
13+
{
14+
15+
public function __construct(
16+
private readonly ImportProjectTask $importProjectTask,
17+
private readonly ProjectRepository $projectRepository,
18+
)
19+
{
20+
parent::__construct();
21+
}
22+
23+
protected function configure()
24+
{
25+
$this
26+
->setName('app:reimport-all-projects')
27+
->setDescription('Re-Imports all projects that have already been imported and updates metadata and relevant composer dependency information.');
28+
}
29+
30+
protected function execute(InputInterface $input, OutputInterface $output): int
31+
{
32+
$errorCode = 0;
33+
34+
$projects = $this->projectRepository->findAll();
35+
36+
foreach ($projects as $project) {
37+
$importSuccess = $this->importProjectTask->run($project->getVcsUrl());
38+
39+
if ($importSuccess) {
40+
$output->writeln('Successfully re-imported '.$project->getVcsUrl());
41+
} else {
42+
$output->writeln('Re-import failed for '.$project->getVcsUrl().'. Make sure you have sufficient repository access and that it contains a composer.lock file. See logs for details.');
43+
$errorCode = 1;
44+
}
45+
}
46+
47+
return $errorCode;
48+
}
49+
}

0 commit comments

Comments
 (0)