Skip to content

Commit

Permalink
fix(remove-pr-from-merge-queue): check last update time before starti…
Browse files Browse the repository at this point in the history
…ng the stale check clock
  • Loading branch information
bherrmann2 committed Jul 11, 2024
1 parent a69b425 commit f6a76af
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/helpers/remove-pr-from-merge-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ export const removePrFromMergeQueue = async ({ seconds }: RemovePrFromMergeQueue
ref: sha,
...context.repo
});
const mostRecentStatus = orderBy(data, 'created_at', 'desc')[0];
const mostRecentStatus = orderBy(data, 'updated_at', 'desc')[0];
const noPendingStatus = data.find(status => status.state !== 'pending');
if (noPendingStatus && mostRecentStatus && timestampIsStale(mostRecentStatus.created_at, seconds)) {
if (noPendingStatus && mostRecentStatus && timestampIsStale(mostRecentStatus.updated_at, seconds)) {
core.info('Removing stale PR from first queued position...');
return Promise.all([removeLabelIfExists(READY_FOR_MERGE_PR_LABEL, number), removeLabelIfExists(FIRST_QUEUED_PR_LABEL, number)]);
}
Expand Down
14 changes: 7 additions & 7 deletions test/helpers/remove-pr-from-merge-queue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ describe('removePrFromMergeQueue', () => {
(octokit.repos.listCommitStatusesForRef as unknown as Mocktokit).mockImplementation(async () => ({
data: [
{
created_at: '2022-01-01T08:59:00Z',
updated_at: '2022-01-01T08:59:00Z',
state: 'failure'
},
{
created_at: '2022-01-01T08:00:00Z',
updated_at: '2022-01-01T08:00:00Z',
state: 'success'
}
]
Expand Down Expand Up @@ -96,11 +96,11 @@ describe('removePrFromMergeQueue', () => {
(octokit.repos.listCommitStatusesForRef as unknown as Mocktokit).mockImplementation(async () => ({
data: [
{
created_at: '2022-01-01T09:01:00Z',
updated_at: '2022-01-01T09:01:00Z',
state: 'failure'
},
{
created_at: '2022-01-01T10:00:00Z',
updated_at: '2022-01-01T10:00:00Z',
state: 'success'
}
]
Expand Down Expand Up @@ -133,15 +133,15 @@ describe('removePrFromMergeQueue', () => {
(octokit.repos.listCommitStatusesForRef as unknown as Mocktokit).mockImplementation(async () => ({
data: [
{
created_at: '2022-01-01T10:00:00Z',
updated_at: '2022-01-01T10:00:00Z',
state: 'failure'
},
{
created_at: '2022-01-01T09:01:00Z',
updated_at: '2022-01-01T09:01:00Z',
state: 'pending'
},
{
created_at: '2022-01-01T10:00:00Z',
updated_at: '2022-01-01T10:00:00Z',
state: 'success'
}
]
Expand Down

0 comments on commit f6a76af

Please sign in to comment.