]> git.kaiwu.me - haproxy.git/commitdiff
DEV: patchbot: pass the branch version to the generated page
authorWilly Tarreau <w@1wt.eu>
Mon, 6 Jul 2026 14:20:50 +0000 (16:20 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 7 Jul 2026 08:58:38 +0000 (10:58 +0200)
The review page will need to exchange its state with the update.cgi
service sitting next to it, and for this it must know which branch it
covers since all branches' pages may share a directory. post-ai.sh
takes a new "-v <version>" argument and emits it as a "branch" JS
variable; when absent the variable is empty and the page will simply
not offer syncing, keeping the output standalone as today.

update-3.0.sh deduces the version from its own name (update-3.0.sh ->
3.0), so that adding a symlink with another version for a new branch
continues to work with no other change, and passes it to post-ai.sh.

dev/patchbot/scripts/post-ai.sh
dev/patchbot/scripts/update-3.0.sh

index 8367912fa1d4905bbc0f1b04109b5f1ae54b6c56..0db78aae906976a6212d9dbdedec420135459862 100755 (executable)
@@ -24,20 +24,30 @@ quit() {
 
 #### Main
 
-USAGE="Usage: ${0##*/} [ -h ] [ -b 'bkp_list' ] patch..."
+USAGE="Usage: ${0##*/} [ -h ] [ -b 'bkp_list' ] [ -v version ] patch..."
 MYSELF="$0"
 GITURL="http://git.haproxy.org/?p=haproxy.git;a=commitdiff;h="
 ISSUES="https://github.com/haproxy/haproxy/issues/"
 BKP=""
+VERSION=""
 
 while [ -n "$1" -a -z "${1##-*}" ]; do
        case "$1" in
                -h|--help) quit "$USAGE" ;;
                -b)        BKP="$2"; shift 2 ;;
+               -v)        VERSION="$2"; shift 2 ;;
                *)         die  "$USAGE" ;;
        esac
 done
 
+# VERSION is the branch this page covers (eg: 3.5). It is only used by the
+# in-page JS to sync the review state with the server-side update.cgi, which
+# strictly validates it, so let's check it here as well. When empty, the
+# syncing UI is not emitted at all and the page keeps working standalone.
+if [ -n "$VERSION" ] && ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+$ ]]; then
+       die "Invalid version '$VERSION', expected <digits>.<digits>"
+fi
+
 PATCHES=( "$@" )
 
 if [ ${#PATCHES[@]} = 0 ]; then
@@ -139,6 +149,11 @@ var nb_patches = 0;
 var cid = [];
 var bkp = [];
 
+// the branch this page covers (eg: "3.5"), used to sync the review state
+// with the server-side update.cgi; empty when generated without -v, in
+// which case no syncing is possible and the page works standalone.
+var branch = '$VERSION';
+
 // first line to review
 var review = 0;
 
index b661f26cb62be7986fdb47a554f61d42b6733462..432a9113d3ac9cc7afe8247cf87d9aa3a1971686 100755 (executable)
@@ -16,6 +16,14 @@ if [ -z "$BRANCH" ]; then
        exit 1
 fi
 
+# The version is deduced from this script's name (update-3.0.sh -> 3.0), so
+# that a symlink with another version continues to work as-is. It's passed
+# to post-ai.sh for the page to know which branch to sync with update.cgi;
+# if the name doesn't match, no version is passed and the page simply won't
+# offer syncing.
+VERSION="${0##*/}"; VERSION="${VERSION#update-}"; VERSION="${VERSION%.sh}"
+[[ "$VERSION" =~ ^[0-9]+\.[0-9]+$ ]] || VERSION=""
+
 # eg: for v3.0-dev0^ we should get v2.9.0 hence "2.9"
 STABLE=$(cd "$HAPROXY_DIR" && git describe --tags "v${BRANCH}-dev0^" |cut -f1,2 -d.|cut -f2- -dv)
 
@@ -64,4 +72,4 @@ fi
 time EXT=m7bv02.txt MODEL=${MODELS_DIR}/mistral-7b-instruct-v0.2.Q5_K_M.gguf CACHE=${PROMPTS_DIR}/prompt-${BRANCH}-m7bv02.cache PROMPT_PFX=${PROMPTS_DIR}/prompt15-${BRANCH}-mist7bv2-pfx.txt PROMPT_SFX=${PROMPTS_DIR}/prompt15-${BRANCH}-mist7bv2-sfx.txt MAINPROG=$MAINPROG PROGRAM="$SCRIPTS_DIR"/process-patch-v15.sh "$SCRIPTS_DIR"/submit-ai.sh -s ${PARALLEL_RUNS} ${PATCHES_DIR}/*.patch
 
 # generate the output, takes 3-5 seconds
-"$SCRIPTS_DIR"/post-ai.sh -b "${BKP[*]}" ${PATCHES_DIR}/*.m7bv02.txt > ${VERDICT_DIR}/verdict-${BRANCH}-m7bv02.html
+"$SCRIPTS_DIR"/post-ai.sh ${VERSION:+-v "$VERSION"} -b "${BKP[*]}" ${PATCHES_DIR}/*.m7bv02.txt > ${VERDICT_DIR}/verdict-${BRANCH}-m7bv02.html