[FIX] manifest: give repo init a branch name, not a bare SHA

repo cannot resolve a commit into a manifest revision on a FRESH workspace:
it gave up on « unparseable HEAD », then repo sync on « manifest not
found ». An already-initialised .repo accepts the SHA, which is why only
new installations were hit — four fresh VMs failed identically.

--- FR ---

repo ne sait pas résoudre un commit en révision de manifeste sur un espace
de travail NEUF : il abandonnait sur « unparseable HEAD », puis repo sync
sur « manifest not found ». Un .repo déjà initialisé accepte le SHA, d'où
un défaut limité aux installations neuves — quatre VM ont échoué ainsi.

Assisted-by: Claude Opus 5
This commit is contained in:
Mathieu Benoit 2026-08-10 03:10:50 -04:00
parent b28b734338
commit c84fbc559d

View file

@ -44,7 +44,28 @@ fi
# Generate local manifest
.venv.erplibre/bin/python ./script/git/git_merge_repo_manifest.py --output .repo/local_manifests/erplibre_manifest.xml --with_OCA
.venv.erplibre/bin/repo init -u git://127.0.0.1:9418/ -b $(git rev-parse --verify HEAD) -m ${MANIFEST_TARGET} "$@"
# Révision du manifeste : un NOM DE BRANCHE, jamais un SHA nu.
#
# « repo init -b <sha> » échoue sur un espace de travail NEUF : repo doit y
# cloner .repo/manifests et ne sait pas résoudre un commit en révision de
# manifeste. Il abandonne sur « unparseable HEAD », puis repo sync sur
# « manifest not found ». Mesuré : -b main réussit, -b <sha> échoue.
# Le piège est qu'un .repo DÉJÀ initialisé accepte le SHA — le défaut reste
# donc invisible sur toute machine ayant réussi un init une fois, et ne frappe
# que les installations neuves : les 4 VM du 2026-08-07 ont toutes échoué là.
MANIFEST_REV=$(git symbolic-ref --quiet --short HEAD || true)
if [ -z "${MANIFEST_REV}" ]; then
# HEAD détaché : prendre une branche qui contient ce commit plutôt que de
# retomber sur le SHA, qui ne marcherait pas.
MANIFEST_REV=$(git branch --contains HEAD --format='%(refname:short)' 2>/dev/null | grep -v '[()]' | head -1)
fi
if [ -z "${MANIFEST_REV}" ]; then
echo "Erreur : impossible de déterminer une branche pour repo init." >&2
echo " HEAD est détaché et aucune branche ne contient ce commit." >&2
exit 1
fi
.venv.erplibre/bin/repo init -u git://127.0.0.1:9418/ -b "${MANIFEST_REV}" -m ${MANIFEST_TARGET} "$@"
.venv.erplibre/bin/repo sync -c -j "$JOBS" ${REPO_VERBOSE} -m ${MANIFEST_TARGET}
# Daemon cleanup handled by the EXIT trap above (tolerant of an already-dead PID).