Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
Shell
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495#!/usr/bin/env bash# Regenerates the web-features map after a merge and commits it, together with the# events that merge produced, as one commit on the current branch. The one entry point# for keeping docs/web-features-map.json current: bench/land.sh runs it in the primary# checkout after every unattended landing, and a hand landing runs it the same way.## bench/web-features-update.sh [--no-commit]## Run from anywhere inside a checkout; it works on that checkout's root. Steps:# 1. refuse if docs/web-features-map.json or docs/web-features-events.jsonl has# uncommitted changes (they are this script's to write)# 2. node oracle/suites/web-features-map.mjs: rewrites the snapshot unless only the# engine commit would change# 3. if the snapshot's content did not change: print "unchanged" and exit 0, with# nothing written and nothing committed# 4. append node oracle/suites/web-features-diff.mjs <old> <new> to# docs/web-features-events.jsonl# 5. commit exactly those two files ("web-features map: ..."), unless --no-commit## Exit 0 when the map is current afterwards (committed, or unchanged); 1 on any failure,# with the reason on stderr and both files put back as they were, so a failure never# leaves the checkout dirty and never touches anything else. It never merges, resets or# pushes. Format and rules: docs/web-features-map.md.set -euo pipefail
NO_COMMIT=0for arg in "$@"; do case "$arg" in --no-commit) NO_COMMIT=1 ;; *) echo "usage: bench/web-features-update.sh [--no-commit]" >&2; exit 1 ;; esacdone
ROOT="$(git -C "$(dirname "${BASH_SOURCE[0]}")" rev-parse --show-toplevel)"cd "$ROOT"MAP=docs/web-features-map.jsonLOG=docs/web-features-events.jsonl
if [ -n "$(git status --porcelain -- "$MAP" "$LOG")" ]; then echo "web-features map not updated: $MAP or $LOG has uncommitted changes" >&2 exit 1fi
TMP="$(mktemp -d)"DONE=0restore() { local code=$? if [ "$DONE" = 0 ]; then git reset -q -- "$MAP" "$LOG" 2>/dev/null || true git checkout -q -- "$MAP" "$LOG" 2>/dev/null || true # A file the checkout did not track yet is removed rather than left behind. for f in "$MAP" "$LOG"; do git ls-files --error-unmatch "$f" >/dev/null 2>&1 || rm -f "$f" done fi rm -rf "$TMP" exit "$code"}trap restore EXIT
if [ -f "$MAP" ]; then cp "$MAP" "$TMP/before.json"; else : >"$TMP/before.json"; fi
if ! node oracle/suites/web-features-map.mjs >&2; then echo "web-features map not updated: the generator failed" >&2 exit 1fi
if [ -s "$TMP/before.json" ] && cmp -s "$TMP/before.json" "$MAP"; then DONE=1 echo "web-features map unchanged" exit 0fi
if ! node oracle/suites/web-features-diff.mjs "$TMP/before.json" "$MAP" >"$TMP/events"; then echo "web-features map not updated: the diff failed" >&2 exit 1ficat "$TMP/events" >>"$LOG"N="$(wc -l <"$TMP/events" | tr -d ' ')"
if [ "$NO_COMMIT" = 1 ]; then DONE=1 echo "web-features map regenerated, $N events appended (not committed)" exit 0fi
AT="$(git rev-parse --short HEAD)"git add -- "$MAP" "$LOG"if ! git commit -q -m "web-features map: regenerate at $AT ($N events)" -- "$MAP" "$LOG"; then echo "web-features map not updated: the commit failed" >&2 exit 1fiDONE=1echo "web-features map committed at $(git rev-parse --short HEAD), $N events"