Skip to content

Commit 7f4e277

Browse files
committed
Adding "dry-run"
1 parent 0265f40 commit 7f4e277

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Command/PingStaleIssuesCommand.php

+10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Symfony\Component\Console\Command\Command;
1313
use Symfony\Component\Console\Input\InputArgument;
1414
use Symfony\Component\Console\Input\InputInterface;
15+
use Symfony\Component\Console\Input\InputOption;
1516
use Symfony\Component\Console\Output\OutputInterface;
1617

1718
/**
@@ -46,6 +47,7 @@ public function __construct(RepositoryProvider $repositoryProvider, IssueApi $is
4647
protected function configure()
4748
{
4849
$this->addArgument('repository', InputArgument::REQUIRED, 'The full name to the repository, eg symfony/symfony-docs');
50+
$this->addOption('dry-run', null, InputOption::VALUE_NONE, 'Do a test search without making any comments or changes');
4951
}
5052

5153
protected function execute(InputInterface $input, OutputInterface $output)
@@ -62,6 +64,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
6264
$notUpdatedAfter = new \DateTimeImmutable(self::STALE_IF_NOT_UPDATED_SINCE);
6365
$issues = $this->issueApi->findStaleIssues($repository, $notUpdatedAfter);
6466

67+
if ($input->getOption('dry-run')) {
68+
foreach ($issues as $issue) {
69+
$output->writeln(sprintf('Marking issue #%s as "Staled". Link https://github.com/%s/issues/%s', $issue['number'], $repository->getFullName(), $issue['number']));
70+
}
71+
72+
return 0;
73+
}
74+
6575
foreach ($issues as $issue) {
6676
$comment = $this->commentGenerator->getComment($this->extractType($issue));
6777
$this->issueApi->commentOnIssue($repository, $issue['number'], $comment);

0 commit comments

Comments
 (0)