Fix PRs that were created before the last tag but merged since it (#8858)

This commit is contained in:
Neil Lathwood
2018-07-03 13:00:58 +01:00
committed by Tony Murray
parent 32691830e6
commit faba6d9d02

View File

@@ -104,16 +104,21 @@ class GitHub
*/
public function getPullRequests($date, $page = 1)
{
$prs = Requests::get($this->github . "/pulls?state=closed&page=$page", $this->getHeaders());
$prs = Requests::get($this->github . "/pulls?state=closed&sort=updated&direction=desc&page=$page", $this->getHeaders());
$prs = json_decode($prs->body, true);
foreach ($prs as $k => $pr) {
if ($pr['merged_at']) {
$created = new DateTime($pr['created_at']);
$merged = new DateTime($pr['merged_at']);
$updated = new DateTime($pr['updated_at']);
$end_date = new DateTime($date);
if (isset($this->pr['merged_at']) && $merged > new DateTime($this->pr['merged_at'])) {
// If the date of this PR is newer than the final PR then skip over it
continue;
} elseif ($merged < $end_date) {
} elseif ($created < $end_date && $merged < $end_date && $updated >= $end_date) {
// If this PR was created and merged before the last tag but has been updated since then skip over
continue;
} elseif ($created < $end_date && $merged < $end_date && $updated < $end_date) {
// If the date of this PR is older than the last release we're done
return true;
} else {