@@ -178,16 +178,20 @@ public function handle(): int
178178 }
179179
180180 // Create GitHub PR
181+ $ prCreated = null ;
181182 if (! $ dry ) {
182- $ this ->createGitHubPr ($ cfg , $ prBranch , $ localBranch , $ prTitle , $ prBody , $ upstreamUrl );
183+ $ prCreated = $ this ->createGitHubPr ($ cfg , $ prBranch , $ localBranch , $ prTitle , $ prBody , $ upstreamUrl );
183184 }
184185
185186 if ($ dry ) {
186187 $ this ->newLine ();
187188 $ this ->info ('✅ Dry run complete - no changes were made. ' );
188189 $ this ->line ('💡 Run without <comment>--dry-run</comment> to execute the pull request creation. ' );
189- } else {
190+ } elseif ( $ prCreated === true ) {
190191 $ this ->info ('✅ Pull request created successfully! ' );
192+ } else {
193+ // Error details already printed inside createGitHubPr()
194+ return self ::FAILURE ;
191195 }
192196
193197 return self ::SUCCESS ;
@@ -234,7 +238,7 @@ private function generatePrBranchName(array $cfg): string
234238 return $ prefix .$ timestamp ;
235239 }
236240
237- private function createGitHubPr (array $ cfg , string $ prBranch , string $ targetBranch , string $ title , string $ body , string $ upstreamUrl ): void
241+ private function createGitHubPr (array $ cfg , string $ prBranch , string $ targetBranch , string $ title , string $ body , string $ upstreamUrl ): bool
238242 {
239243 $ token = $ cfg ['github_token ' ];
240244 $ owner = $ cfg ['github_owner ' ];
@@ -243,8 +247,7 @@ private function createGitHubPr(array $cfg, string $prBranch, string $targetBran
243247 if (! $ token || ! $ owner || ! $ repo ) {
244248 $ this ->warn ('⚠️ GitHub credentials not configured. Please set GITHUB_TOKEN, GITHUB_OWNER, and GITHUB_REPO in your .env file. ' );
245249 $ this ->line ("🔗 You can manually create a PR at: https://github.com/ $ owner/ $ repo/compare/ $ targetBranch... $ prBranch " );
246-
247- return ;
250+ return false ;
248251 }
249252
250253 $ this ->line ('📤 Creating GitHub pull request... ' );
@@ -262,10 +265,14 @@ private function createGitHubPr(array $cfg, string $prBranch, string $targetBran
262265
263266 if ($ response && isset ($ response ['html_url ' ])) {
264267 $ this ->info ("✅ Pull request created: {$ response ['html_url ' ]}" );
265- } else {
266- $ this ->error ('❌ Failed to create pull request. ' );
267- $ this ->line ("🔗 You can manually create a PR at: https://github.com/ $ owner/ $ repo/compare/ $ targetBranch... $ prBranch " );
268+ return true ;
268269 }
270+
271+ // Failed
272+ $ this ->error ('❌ Failed to create pull request. ' );
273+ $ this ->line ("🔗 You can manually create a PR at: https://github.com/ $ owner/ $ repo/compare/ $ targetBranch... $ prBranch " );
274+
275+ return false ;
269276 }
270277
271278 private function makeGitHubRequest (string $ token , string $ owner , string $ repo , array $ data ): ?array
0 commit comments