Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch commit author avatar in getCommit and getLatestCommit #31

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/VCS/Adapter/Git/GitHub.php
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ public function getCommit(string $owner, string $repositoryName, string $commitH
return [
'commitAuthor' => $response['body']['commit']['author']['name'],
'commitMessage' => $response['body']['commit']['message'],
'commitAuthorAvatar' => $response['body']['author']['avatar_url'],
];
}

Expand All @@ -473,7 +474,8 @@ public function getLatestCommit(string $owner, string $repositoryName, string $b
!isset($response['body']['commit']['author']['name']) ||
!isset($response['body']['commit']['message']) ||
!isset($response['body']['sha']) ||
!isset($response['body']['html_url'])
!isset($response['body']['html_url']) ||
!isset($response['body']['author']['avatar_url'])
) {
throw new Exception("Latest commit response is missing required information.");
}
Expand All @@ -482,7 +484,8 @@ public function getLatestCommit(string $owner, string $repositoryName, string $b
'commitAuthor' => $response['body']['commit']['author']['name'],
'commitMessage' => $response['body']['commit']['message'],
'commitHash' => $response['body']['sha'],
'commitUrl' => $response['body']['html_url']
'commitUrl' => $response['body']['html_url'],
'commitAuthorAvatar' => $response['body']['author']['avatar_url'],
];
}

Expand Down
2 changes: 2 additions & 0 deletions tests/VCS/Adapter/GitHubTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,13 @@ public function testGetCommit(): void
{
$commitDetails = $this->vcsAdapter->getCommit('test-kh', 'test1', '7ae65094d56edafc48596ffbb77950e741e56412');
$this->assertIsArray($commitDetails);
$this->assertEquals('https://avatars.githubusercontent.com/u/43381712?v=4', $commitDetails['commitAuthorAvatar']);
}

public function testGetLatestCommit(): void
{
$commitDetails = $this->vcsAdapter->getLatestCommit('test-kh', 'test1', 'test');
$this->assertEquals('Khushboo Verma', $commitDetails['commitAuthor']);
$this->assertEquals('https://avatars.githubusercontent.com/u/43381712?v=4', $commitDetails['commitAuthorAvatar']);
}
}
Loading