diff --git a/dev-infra/ng-dev.js b/dev-infra/ng-dev.js index 3c464e170a..617acc5822 100755 --- a/dev-infra/ng-dev.js +++ b/dev-infra/ng-dev.js @@ -5327,6 +5327,8 @@ const findOwnedForksOfRepoQuery = typedGraphqlify.params({ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ +/** Thirty seconds in milliseconds. */ +const THIRTY_SECONDS_IN_MS = 30000; /** Gets whether a given pull request has been merged. */ function getPullRequestState(api, id) { return tslib.__awaiter(this, void 0, void 0, function* () { @@ -5334,12 +5336,15 @@ function getPullRequestState(api, id) { if (data.merged) { return 'merged'; } - else if (data.closed_at !== null) { + // Check if the PR was closed more than 30 seconds ago, this extra time gives Github time to + // update the closed pull request to be associated with the closing commit. + // Note: a Date constructed with `null` creates an object at 0 time, which will never be greater + // than the current date time. + if (data.closed_at !== null && + (new Date(data.closed_at).getTime() < Date.now() - THIRTY_SECONDS_IN_MS)) { return (yield isPullRequestClosedWithAssociatedCommit(api, id)) ? 'merged' : 'closed'; } - else { - return 'open'; - } + return 'open'; }); } /** diff --git a/dev-infra/release/publish/pull-request-state.ts b/dev-infra/release/publish/pull-request-state.ts index 9f318ee406..129ef2dba5 100644 --- a/dev-infra/release/publish/pull-request-state.ts +++ b/dev-infra/release/publish/pull-request-state.ts @@ -9,6 +9,9 @@ import * as Octokit from '@octokit/rest'; import {GitClient} from '../../utils/git/index'; +/** Thirty seconds in milliseconds. */ +const THIRTY_SECONDS_IN_MS = 30000; + /** State of a pull request in Github. */ export type PullRequestState = 'merged'|'closed'|'open'; @@ -17,11 +20,16 @@ export async function getPullRequestState(api: GitClient, id: number): Promise