Skip to content

Commit f678415

Browse files
committed
Commit list between two tags
1 parent 7016156 commit f678415

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/CommitFetcher.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,36 @@ private function getListDateRange(string $since, string $until): array {
4949

5050
return $return;
5151
}
52+
53+
public function getCommitListBetweenTags(string $startTag, string $untilTag): array {
54+
$params = [
55+
'page' => 1,
56+
];
57+
58+
$baseUrl = static::API_ENDPOINT_COMPARE;
59+
$baseUrl .= $startTag . '...' . $untilTag;
60+
61+
$return = [];
62+
$hardLimits = 50;
63+
64+
do {
65+
$paramsUrl = http_build_query($params);
66+
$url = $baseUrl . '?' .$paramsUrl;
67+
68+
$headers = [];
69+
if ($this->apiKey) {
70+
$headers[] = 'Authorization: Bearer '. $this->apiKey;
71+
}
72+
73+
$data = $this->curlFetcher->getJson($url, $headers);
74+
/** @noinspection SlowArrayOperationsInLoopInspection */
75+
$return = array_merge($return, $data->commits);
76+
77+
$params['page']++;
78+
$hardLimits--;
79+
80+
} while (count($data->commits) >= 250 && $hardLimits > 0);
81+
82+
return $return;
83+
}
5284
}

0 commit comments

Comments
 (0)