Skip to content

Commit

Permalink
Merge pull request #29 from utopia-php/feat-add-avatar0url
Browse files Browse the repository at this point in the history
Fetch link of user's git avatar from push/PR event payloads
  • Loading branch information
vermakhushboo authored Nov 11, 2024
2 parents 125c136 + 530ef6c commit d90ee68
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/VCS/Adapter/Git/GitHub.php
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ public function getEvent(string $event, string $payload): array
$commitHash = $payload['after'] ?? '';
$owner = $payload['repository']['owner']['name'] ?? '';
$authorUrl = $payload['sender']['html_url'];
$authorAvatarUrl = $payload['sender']['avatar_url'] ?? '';
$headCommitAuthor = $payload['head_commit']['author']['name'] ?? '';
$headCommitMessage = $payload['head_commit']['message'] ?? '';
$headCommitUrl = $payload['head_commit']['url'] ?? '';
Expand All @@ -597,6 +598,7 @@ public function getEvent(string $event, string $payload): array
'commitHash' => $commitHash,
'owner' => $owner,
'authorUrl' => $authorUrl,
'authorAvatarUrl' => $authorAvatarUrl,
'headCommitAuthor' => $headCommitAuthor,
'headCommitMessage' => $headCommitMessage,
'headCommitUrl' => $headCommitUrl,
Expand All @@ -614,6 +616,7 @@ public function getEvent(string $event, string $payload): array
$action = $payload['action'] ?? '';
$owner = $payload['repository']['owner']['login'] ?? '';
$authorUrl = $payload['sender']['html_url'];
$authorAvatarUrl = $payload['pull_request']['user']['avatar_url'] ?? '';
$commitHash = $payload['pull_request']['head']['sha'] ?? '';
$headCommitUrl = $repositoryUrl . "/commits/" . $commitHash;
$external = $payload['pull_request']['head']['user']['login'] !== $payload['pull_request']['base']['user']['login'];
Expand All @@ -628,6 +631,7 @@ public function getEvent(string $event, string $payload): array
'commitHash' => $commitHash,
'owner' => $owner,
'authorUrl' => $authorUrl,
'authorAvatarUrl' => $authorAvatarUrl,
'headCommitUrl' => $headCommitUrl,
'external' => $external,
'pullRequestNumber' => $pullRequestNumber,
Expand Down
7 changes: 6 additions & 1 deletion tests/VCS/Adapter/GitHubTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public function testgetEvent(): void
"url": "https://github.com/vermakhushboo/g4-node-function/commit/b787f03343171ff5a477627796140bfa1d02da09"
},
"sender": {
"html_url": "https://github.com/vermakhushboo"
"html_url": "https://github.com/vermakhushboo",
"avatar_url": "https://avatars.githubusercontent.com/u/43381712?v=4"
}
}';

Expand All @@ -78,6 +79,10 @@ public function testgetEvent(): void
"user": {
"login": "vermakhushboo"
}
},
"user" : {
"login": "vermakhushboo",
"avatar_url": "https://avatars.githubusercontent.com/u/43381712?v=4"
}
},
"repository": {
Expand Down

0 comments on commit d90ee68

Please sign in to comment.