Skip to content

Commit 9a58b9e

Browse files
authored
Merge pull request #52 from utopia-php/fix-get-commit
Fix: get commit missing details
2 parents 44035d3 + 62491de commit 9a58b9e

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

src/VCS/Adapter/Git/GitHub.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -494,17 +494,18 @@ public function getCommit(string $owner, string $repositoryName, string $commitH
494494

495495
$response = $this->call(self::METHOD_GET, $url, ['Authorization' => "Bearer $this->accessToken"]);
496496

497-
if (!isset($response['body']['commit']['author']['name']) || !isset($response['body']['commit']['message'])) {
498-
throw new Exception("Commit author or message information missing.");
499-
}
497+
$body = $response['body'] ?? [];
498+
$author = $body['author'] ?? [];
499+
$commit = $body['commit'] ?? [];
500+
$commitAuthor = $commit['author'] ?? [];
500501

501502
return [
502-
'commitAuthor' => $response['body']['commit']['author']['name'],
503-
'commitMessage' => $response['body']['commit']['message'],
504-
'commitAuthorAvatar' => $response['body']['author']['avatar_url'],
505-
'commitAuthorUrl' => $response['body']['author']['html_url'],
506-
'commitHash' => $response['body']['sha'],
507-
'commitUrl' => $response['body']['html_url'],
503+
'commitAuthor' => $commitAuthor['name'] ?? 'Unknown',
504+
'commitMessage' => $commit['message'] ?? 'No message',
505+
'commitAuthorAvatar' => $author['avatar_url'] ?? '',
506+
'commitAuthorUrl' => $author['html_url'] ?? '',
507+
'commitHash' => $body['sha'] ?? '',
508+
'commitUrl' => $body['html_url'] ?? '',
508509
];
509510
}
510511

0 commit comments

Comments
 (0)