workflows/labels: handle PR-creation-edge-case for merge conflict label

Explained very well by the code comment.

(cherry picked from commit 39dc87db4b)
This commit is contained in:
Wolfgang Walther
2025-06-24 19:43:57 +02:00
committed by github-actions[bot]
parent 3460ac2fbb
commit e803fd6d97

View File

@@ -255,6 +255,13 @@ jobs:
const stale_at = new Date(new Date().setDate(new Date().getDate() - 180))
// After creation of a Pull Request, `merge_commit_sha` will be null initially:
// The very first merge commit will only be calculated after a little while.
// To avoid labeling the PR as conflicted before that, we wait a few minutes.
// This is intentionally less than the time that Eval takes, so that the label job
// running after Eval can indeed label the PR as conflicted if that is the case.
const merge_commit_sha_valid = new Date() - new Date(pull_request.created_at) > 3 * 60 * 1000
// Manage most of the labels, without eval results
const after = Object.assign(
{},
@@ -271,7 +278,7 @@ jobs:
// On the first pass of the day, we just fetch the pull request, which triggers
// the creation. At this stage, the label is likely not updated, yet.
// The second pass will then read the result from the first pass and set the label.
'2.status: merge conflict': !pull_request.merge_commit_sha,
'2.status: merge conflict': merge_commit_sha_valid && !pull_request.merge_commit_sha,
'2.status: stale': !before['1.severity: security'] && latest_event_at < stale_at,
'12.approvals: 1': approvals.size == 1,
'12.approvals: 2': approvals.size == 2,