Files
RedBear-OS/local/scripts/bump-build-version.sh
T
vasilito 81f738f7bd build system: brush versioning fix + build-redbear.sh versioning/colors/prefix honesty
sync-versions: stop stamping vendored-upstream workspaces with the Cat 1
branch version. brush is a vendored upstream (reubeno/brush) whose 12 crates
carry their own upstream versions with internal ^ requirements (brush needs
brush-parser ^0.4.0, brush-core 0.5.0, ...); rewriting them all to 0.3.1 broke
the build. The old git-untracked heuristic stopped catching brush once it was
vendored (committed). Add a provenance-based .vendored-upstream opt-out marker
(covers the whole class, not just brush) read by should_exclude.

build-redbear.sh:
- versioning: BUILD_REDBEAR_VERSION (starts 1.0), --version flag, startup
  banner, auto-bumped by pre-commit hook (bump-build-version.sh)
- colored output (TTY + NO_COLOR aware)
- prefix rebuild: stop reporting 'rebuilt successfully' on a make no-op;
  remove derived prefix markers so a stale relibc actually re-cooks into the
  sysroot; skip the rebuild when only kernel/base (which don't feed the prefix)
  advanced
- record fork source-fingerprints only after a successful build (not before
  make live), so a failed build no longer marks forks as built

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-27 12:30:55 +09:00

46 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# bump-build-version.sh — git pre-commit hook.
#
# Auto-increments the minor of BUILD_REDBEAR_VERSION in
# local/scripts/build-redbear.sh whenever that file is part of the commit.
# The version starts at 1.0 and bumps to 1.1, 1.2, … on every committed change,
# so the version printed at build start always reflects how many times the
# orchestrator has changed. No manual editing of the minor is needed.
#
# Installed via: ./local/scripts/install-git-hooks.sh --all
# Bypass a single commit with: git commit --no-verify
#
# Limitation: re-staging happens at whole-file granularity, so a partial
# (`git add -p`) stage of build-redbear.sh will be promoted to the full file.
# That is the standard trade-off for a re-staging pre-commit hook.
set -euo pipefail
REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null)" || exit 0
FILE="local/scripts/build-redbear.sh"
# Only act if the build script is actually staged for this commit.
if ! git diff --cached --name-only -- "$FILE" | grep -qx "$FILE"; then
exit 0
fi
# Read the version from the STAGED content (what will actually be committed).
cur="$(git show ":$FILE" 2>/dev/null \
| grep -m1 -oE 'BUILD_REDBEAR_VERSION="[0-9]+\.[0-9]+"' \
| grep -oE '[0-9]+\.[0-9]+' || true)"
if [ -z "$cur" ]; then
# Version constant not found (unexpected) — do not block the commit.
exit 0
fi
major="${cur%%.*}"
minor="${cur#*.}"
new="${major}.$((minor + 1))"
# Update the working-tree file and re-stage so the commit records the bump.
sed -i -E "s/^BUILD_REDBEAR_VERSION=\"[0-9]+\.[0-9]+\"/BUILD_REDBEAR_VERSION=\"${new}\"/" \
"$REPO_ROOT/$FILE"
git add "$FILE"
echo "bump-build-version: build-redbear.sh ${cur} -> ${new}"
exit 0