Merge remote-tracking branch 'origin/master' into fix/rollout-website-approval

# Conflicts:
#	packages/client/ui-primitives/src/clipboard.ts
This commit is contained in:
winewill committed 2026-11-13 14:50:54 +08:00
commit c61a9b8a4f
2 files changed
+25 -18

No files matched your search

+8 -12
View File
@@ -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 [email protected] 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"
+17 -6
View File
@@ -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<boolean> {
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,12 +30,8 @@ export async function writeClipboard(text: string): Promise<boolean> {
// 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 {
return await navigator.clipboard.writeText(text).then(() => 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.