From 0e54263031077f969d629bc89d123f0fa24c19e0 Mon Sep 17 00:00:00 2001 From: mydnic Date: Mon, 6 Jan 2025 10:31:53 +0000 Subject: [PATCH] Fix styling --- src/Commands/FetchGithubCommitCommand.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/Commands/FetchGithubCommitCommand.php b/src/Commands/FetchGithubCommitCommand.php index 194ae50..fcf41eb 100644 --- a/src/Commands/FetchGithubCommitCommand.php +++ b/src/Commands/FetchGithubCommitCommand.php @@ -45,17 +45,17 @@ public function fetchCommits(): Collection $commits = collect(); foreach (config('changelog-commit-for-laravel.github_repositories') as $repository) { - $branch = [ - 'sha' => '', - 'name' => '' + $branch = [ + 'sha' => '', + 'name' => '', ]; - - if(is_array($repository)){ + + if (is_array($repository)) { $branch['sha'] = '?sha='.$repository[1]; $branch['name'] = $repository[1]; $repository = $repository[0]; } else { - $branch['name'] = 'main'; + $branch['name'] = 'main'; } $repoCommits = Http::withHeaders([ @@ -64,20 +64,21 @@ public function fetchCommits(): Collection 'X-GitHub-Api-Version' => '2022-11-28', ]) ->get('https://api.github.com/repos/'.$repository.'/commits'.$branch['sha']); - - if(!$repoCommits->successful()){ - $this->error("Error while getting commit messages: " . $repoCommits->json()['message']); + + if (! $repoCommits->successful()) { + $this->error('Error while getting commit messages: '.$repoCommits->json()['message']); + return collect(); } foreach ($repoCommits->json() as $commit) { $commits->push([ 'branch' => $branch['name'], - 'github' => $commit + 'github' => $commit, ]); } } - + return $commits; } }