Skip to content

Commit f705b9e

Browse files
Copilotmglaman
andauthored
issue:checkout: auto-select branch when only one exists (#331)
* Initial plan * feat: auto-select branch when only one issue branch exists in issue:checkout Co-authored-by: mglaman <3698644+mglaman@users.noreply.github.com> Agent-Logs-Url: https://github.com/mglaman/drupalorg-cli/sessions/fca71fd2-9aa3-4709-9cb7-b188180555e7 --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: mglaman <3698644+mglaman@users.noreply.github.com>
1 parent beca07a commit f705b9e

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

src/Cli/Command/Issue/Checkout.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,24 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9696
$this->stdErr->writeln('<error>No branches found for this issue on the fork.</error>');
9797
return 1;
9898
}
99-
if (!self::$interactive) {
99+
if (count($issueBranches) === 1) {
100+
$branchArg = $issueBranches[0];
101+
$this->stdOut->writeln(sprintf('<info>Auto-selected branch %s.</info>', $branchArg));
102+
} elseif (!self::$interactive) {
100103
$this->stdErr->writeln('<error>No branch specified. Available branches:</error>');
101104
foreach ($issueBranches as $b) {
102105
$this->stdErr->writeln(' ' . $b);
103106
}
104107
return 1;
108+
} else {
109+
/** @var \Symfony\Component\Console\Helper\QuestionHelper $helper */
110+
$helper = $this->getHelper('question');
111+
$question = new \Symfony\Component\Console\Question\ChoiceQuestion(
112+
'Select a branch to check out:',
113+
$issueBranches
114+
);
115+
$branchArg = $helper->ask($input, $output, $question);
105116
}
106-
/** @var \Symfony\Component\Console\Helper\QuestionHelper $helper */
107-
$helper = $this->getHelper('question');
108-
$question = new \Symfony\Component\Console\Question\ChoiceQuestion(
109-
'Select a branch to check out:',
110-
$issueBranches
111-
);
112-
$branchArg = $helper->ask($input, $output, $question);
113117
}
114118

115119
$checkoutProcess = new Process([

0 commit comments

Comments
 (0)