Utilisez git bisect pour retrouver le commit qui introduit un bug.
objectifs d’apprentissage
- Démarrer bisect.
- Marquer good/bad.
- Automatiser avec un script.
prérequis
- Test reproductible.
- Plage de commits connue.
notions clés
- Recherche binaire.
- good/bad.
- bisect run.
démonstration guidée
étape 1
Exécution manuelle de bisect.
git bisect start
git bisect bad HEAD
git bisect good v0.1.0
# tester, puis marquer good/bad à chaque étape
étape 2
Automatiser avec un script d’oracle.
git bisect run bash -c 'pytest -q || exit 1'
exercice
Écrivez un script test.sh qui retourne 0 si le bug est absent, 1 sinon, et utilisez bisect run.
correction
Oracle minimal.
#!/usr/bin/env bash
set -euo pipefail
python - <<'PY'
# renvoyer 1 si bug reproduit (exemple)
import sys; sys.exit(1)
PY
quiz éclair
- Quelle commande lance bisect en mode automatique ?
- a) git bisect run
- b) git bisect auto
- c) git find-bug