Skip to content

Commit

Permalink
Merge pull request #31 from utopia-php/feat-fetch-commit-author
Browse files Browse the repository at this point in the history
Fetch commit author avatar in getCommit and getLatestCommit
  • Loading branch information
vermakhushboo authored Nov 11, 2024
2 parents cab8386 + ce52040 commit 7622330
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
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']);
}
}

0 comments on commit 7622330

Please sign in to comment.