Skip to content

Commit beca07a

Browse files
CopilotmglamanCopilot
authored
issue:checkout: fetch remote before checkout when remote already exists (#330)
* Initial plan * Fix issue:checkout to fetch remote when it already exists Co-authored-by: mglaman <3698644+mglaman@users.noreply.github.com> Agent-Logs-Url: https://github.com/mglaman/drupalorg-cli/sessions/90a6c0b6-a6a3-4e52-b398-95a0e564634a * Update src/Cli/Command/Issue/Checkout.php Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: mglaman <3698644+mglaman@users.noreply.github.com> Co-authored-by: Matt Glaman <nmd.matt@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent c77961c commit beca07a

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/Cli/Command/Issue/Checkout.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7070
);
7171
// Refresh fork data after setup so branches are populated.
7272
$fork = $action($this->nid);
73+
} else {
74+
// Remote already exists; fetch to ensure tracking refs are up-to-date.
75+
$fetchProcess = new Process(['git', 'fetch', $fork->remoteName]);
76+
$fetchProcess->run();
77+
if (!$fetchProcess->isSuccessful()) {
78+
$fetchOutput = trim($fetchProcess->getErrorOutput() . $fetchProcess->getOutput());
79+
$this->stdErr->writeln(
80+
sprintf('<error>Failed to fetch remote %s: %s</error>', $fork->remoteName, $fetchOutput)
81+
);
82+
return 1;
83+
}
7384
}
7485

7586
// Filter branches to those starting with the issue NID.

0 commit comments

Comments
 (0)