From 25e7fe12af8f23dfdf132e4ca464675b912a117e Mon Sep 17 00:00:00 2001 From: imccyu Date: Fri, 13 Nov 2026 14:37:45 +0800 Subject: [PATCH 1/2] ci: fetch the pre-merge history by depth instead of by date The pre-merge step fetched the history since the master diff check's window start. A date window marks a master merge commit shallow when its pull-request parent predates the window, which drops its master parent too, so the merge base settled on an older commit and the merge reported conflicts GitHub did not see (#8095, #8268). The step now fetches 150 commits of both sides without blobs, enough for the base-branch commits a 72-hour-old base can be behind, and reports a missing common commit instead of a conflict. --- .github/workflows/pr-check-on-head-branch.yml | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/.github/workflows/pr-check-on-head-branch.yml b/.github/workflows/pr-check-on-head-branch.yml index ef456f5a9b..7882c35d5b 100644 --- a/.github/workflows/pr-check-on-head-branch.yml +++ b/.github/workflows/pr-check-on-head-branch.yml @@ -65,7 +65,6 @@ jobs: CHECK_MODE: ${{ vars.MERGE_POLICY_PRE_MERGE }} BASE_SHA: ${{ needs.master.outputs.base_sha }} HEAD_SHA: ${{ github.event.pull_request.head.sha }} - SINCE: ${{ needs.master.outputs.since }} run: | stop() { if [ "$CHECK_MODE" = block ]; then @@ -75,21 +74,18 @@ jobs: echo "::warning title=Pre-Merge Check::$1" exit 0 } - if [[ ! "$BASE_SHA" =~ ^[0-9a-f]{40}$ || ! "$SINCE" =~ ^[0-9]+$ ]]; then + if [[ ! "$BASE_SHA" =~ ^[0-9a-f]{40}$ ]]; then stop "the master diff check reported no base commit, so nothing was merged or compiled" fi - # A shallow fetch starts a background maintenance run that rewrites .git/shallow, and the second shallow fetch - # below then fails with "shallow file has changed since we read it". - fetch() { - git -c maintenance.auto=false -c gc.auto=0 fetch --no-tags --no-write-fetch-head "$@" origin "$HEAD_SHA" "$BASE_SHA" - } - fetch --shallow-since="$SINCE" || + # The checkout is already shallow, and a shallow fetch starts a background maintenance run that rewrites + # .git/shallow, so the fetch below would fail with "shallow file has changed since we read it". + # The history is bounded by depth, not by date: a date window marks a merge commit shallow when one parent + # predates it, which drops the other parent too and lets the merge base settle on an older commit. Within its + # depth every commit keeps all parents; 150 covers the base-branch commits a 72-hour-old base can be behind. + git -c maintenance.auto=false -c gc.auto=0 fetch --no-tags --no-write-fetch-head --depth=150 --filter=blob:none origin "$HEAD_SHA" "$BASE_SHA" || stop "the base commit $BASE_SHA could not be fetched, so nothing was merged or compiled" - # A time window records a merge commit itself as shallow when one of its parents predates the window, which - # drops the other, in-window parent too; a depth bound keeps both parents of every commit it covers. if ! git merge-base "$HEAD_SHA" "$BASE_SHA" >/dev/null; then - fetch --depth=20 --filter=blob:none || - stop "the base commit $BASE_SHA could not be fetched, so nothing was merged or compiled" + stop "the pull request shares no commit with $BASE_SHA within 150 commits of history, so nothing was merged or compiled; merge master into it and push, then this check runs again" fi git -c user.name=pr-check -c user.email=pr-check@users.noreply.github.com merge --no-ff --no-edit -m "Merge $BASE_SHA into $HEAD_SHA" "$BASE_SHA" || stop "the pull request cannot merge $BASE_SHA; merge master into it and push, then this check runs again" From 54330f75e432530d571b95f7d8fe214bfe9f5d71 Mon Sep 17 00:00:00 2001 From: imccyu <276526105+imccyu@users.noreply.github.com> Date: Fri, 13 Nov 2026 14:34:55 +0800 Subject: [PATCH 2/2] fix(ui-primitives): keep the clipboard try to one statement --- .../client/ui-primitives/src/clipboard.ts | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/packages/client/ui-primitives/src/clipboard.ts b/packages/client/ui-primitives/src/clipboard.ts index f8331f12e2..c0cf711c2c 100644 --- a/packages/client/ui-primitives/src/clipboard.ts +++ b/packages/client/ui-primitives/src/clipboard.ts @@ -2,6 +2,21 @@ // with each control; this helper reports whether the host accepted a write and // leaves focus where it found it. +/** + * Attempt the async Clipboard API write. + * @param text - the exact text to place on the clipboard. + * @returns true only when the host accepted the write. + */ +async function writeWithClipboardApi(text: string): Promise { + try { + await navigator.clipboard.writeText(text) + } catch (_error) { + // A denied permission can block the async API while execCommand still works; the caller tries it below. + return false + } + return true +} + /** * Write text to the host clipboard, preferring the async Clipboard API and * falling back to `execCommand('copy')` when that API is missing (jsdom, @@ -15,13 +30,8 @@ export async function writeClipboard(text: string): Promise { // lib.dom types clipboard non-optional, but insecure contexts omit it — // that runtime gap is exactly what this guard detects. /* oxlint-disable-next-line typescript/no-unnecessary-condition */ - if (navigator.clipboard?.writeText) { - try { - await navigator.clipboard.writeText(text) - return true - } catch (_error) { - // A denied permission can block the async API while execCommand still works; try it below. - } + if (typeof navigator.clipboard?.writeText === 'function') { + if (await writeWithClipboardApi(text)) return true } // execCommand('copy') is the only clipboard fallback where the async API // is missing or refused; deprecated but deliberately retained.