\begin{frame} \frametitle{Inspection} \framesubtitle{log} Comparer les branches du dépôt \emph{exercices} en explorant les différentes options de git log (--graph, --all, --decorate, .., ...) \commande{git log} % contenu (pas trop long) de la diapositive \end{frame} \begin{frame} \frametitle{Inspection} \framesubtitle{log} \begin{tikzpicture} \begin{pgflowlevelscope}{\pgftransformscale{0.5}} \gitDAG[grow right sep=1em]{ fcacc8a -- a3a980c -- {6d7f839 -- {d221665 -- 841f693 -- f5965df -- a12f94b -- 5464ee7, fe0c2b7 -- 6212e29 -- 0f13577 -- a60f3ed, f81ca5c, 7e54de0}, 30a5821, b13bcf2, 902ae87} }; \gitbranch {master} {above=of 6d7f839} {6d7f839} \gitbranch {brancheindiscrete} {right=of 902ae87} {902ae87} \gitbranch {merge/conflit} {right=of 30a5821} {30a5821} \gitbranch {merge/automatique} {right=of b13bcf2} {b13bcf2} \gitbranch {merge/rebase} {right=of 7e54de0} {7e54de0} \gitbranch {branche/perdue} {right=of f81ca5c} {f81ca5c} \gitbranch {branche/minee} {above=of 5464ee7} {5464ee7} \gitbranch {histoire/confuse} {right=of a60f3ed} {a60f3ed} \end{pgflowlevelscope} \end{tikzpicture} \end{frame} \begin{frame} \frametitle{Inspection} \framesubtitle{bisect} \begin{minipage}{\textwidth} \begin{tikzpicture} %\begin{pgflowlevelscope}{\pgftransformscale{0.5}} \begin{pgflowlevel}{\pgftransformscale{0.6}} \gitDAG[grow right sep=1em]{ fcacc8a -- a3a980c -- {6d7f839 -- {d221665 -- 841f693 -- f5965df -- a12f94b -- 5464ee7}} }; \gitbranch {master} {above=of 6d7f839} {6d7f839} \gitbranch {branche/minee} {above=of 5464ee7} {5464ee7} %\end{pgflowlevelscope} \end{pgflowlevel} \end{tikzpicture} \end{minipage} La branche minee schématise une situation dans laquelle un dysfonctionnement a été introduit mais pas détecté aussitôt. Un script \emph{test.sh} a été ajouté pour simuler le test du code. Il retourne \emph{0} lorsque le code est bon, \emph{1} lorsque le code est mauvais. L'exercice consiste donc à utiliser la commande \commande{git bisect} pour repérer le commit ayant introduit l'erreur, c'est-à-dire à partir duquel le script retourne \emph{1}. \end{frame} \begin{frame} \frametitle{Inspection} \framesubtitle{bisect} Conditions de départ : \begin{itemize} \item dernier \emph{commit} de la branche \emph{branche/minee} \item dernier état du code fonctionnel : dernier \emph{commit} de la branche \emph{master}. \end{itemize} \begin{enumerate}[<+->] \item \commande{git checkout branche/minee} \item \commande{git bisect start} \# démarrage de la session de recherche \item \commande{git bisect bad} \# déclaration de l'état du dernier \emph{commit} \item \commande{git bisect good \$(git log --oneline -1 --format=\%h master)} \# déclaration du dernier état fonctionnel connu \end{enumerate} % contenu (pas trop long) de la diapositive \end{frame} \begin{frame} \frametitle{Inspection} \framesubtitle{bisect} À chaque déplacement contrôlé par \commande{git bisect}, exécuter \emph{test.sh} et indiquer si l'état est fonctionnel : \commande{./test.sh; [[ \$? -eq 0 ]] \&\& git bisect good || git bisect bad} \end{frame} \begin{frame} \frametitle{Inspection} \framesubtitle{bisect} \commande{a12f94b62f617417f4b1f8c5317bc2f033c92f5a is the first bad commit} Terminer la session de recherche : \commande{git bisect reset} \end{frame} \begin{frame} \frametitle{Inspection} \framesubtitle{blame} La conclusion précédente, vu la simplicité du code en cause, aurait pu être tirée grâce à \commande{git blame} et \commande{git log}. % contenu (pas trop long) de la diapositive \end{frame} \begin{frame} \frametitle{Inspection} \framesubtitle{blame} \begin{itemize} \item \commande{git blame test.sh} \item \commande{git log -S"exit 1" test.sh} \end{itemize} \end{frame}