Skip to content

Commit 74363da

Browse files
committed
Add \PHPWatch\PHPCommitBuilder\TagListFetcher::getSingleTagDate
1 parent 0beb569 commit 74363da

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/CommitFetcher.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,8 @@ public function getCommitListBetweenTags(string $startTag, string $untilTag): ar
7979

8080
return $return;
8181
}
82+
83+
public function getCommitByTag(string $tagName): \stdClass {
84+
https://api.github.com/repos/OWNER/REPO/git/tags/TAG_SHA
85+
}
8286
}

src/TagListFetcher.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
class TagListFetcher {
99
private const API_ENDPOINT_TAG_LIST = 'https://api.github.com/repos/php/php-src/tags';
10+
private const API_ENDPOINT_TAG_INDIVIDUAL = 'https://api.github.com/repos/php/php-src/git/commits/%tag';
1011

1112
private const REGEX_TAG_PATTERN = '/^php-\d\.\d\.(?:\d\d?|0(?:alpha\d|beta\d|rc\d|RC\d)?)$/i';
1213
private ?string $apiKey;
@@ -54,4 +55,16 @@ public function getAllTags(): array {
5455

5556
return $return;
5657
}
58+
59+
public function getSingleTagDate(string $tagHash): string {
60+
$baseUrl = strtr(static::API_ENDPOINT_TAG_INDIVIDUAL, ['%tag' => $tagHash]);
61+
62+
$headers = [];
63+
if ($this->apiKey) {
64+
$headers[] = 'Authorization: Bearer ' . $this->apiKey;
65+
}
66+
67+
$tagInfo = $this->curlFetcher->getJson($baseUrl, $headers);
68+
return substr($tagInfo->author->date, 0, 10);
69+
}
5770
}

0 commit comments

Comments
 (0)