oh-my-git/levels/it_IT/index/steps

54 lines
1.7 KiB
Text
Raw Normal View History

2021-09-14 17:03:17 +02:00
title = Aggiungi modifice passo dopo passo
2021-02-04 12:01:58 +01:00
cards = add reset-file commit
[description]
2021-09-14 17:03:17 +02:00
L'indice è veramente utile perché ci permette di essere precisi su quali cambiamenti vogliamo includere in ogni commit!
[setup]
2021-09-14 17:03:17 +02:00
echo "Un martello, in equilibrio sul suo manico." > hammer
echo "Una bottiglia contenente un liquido trasparente." > bottle
echo "Un cubo di zucche bianco." > sugar_cube
git add .
2021-09-14 17:03:17 +02:00
git commit -m "L'inizio"
[win]
2021-09-14 17:03:17 +02:00
# Fai dei cambiamenti a tutti e tre gli oggetti per creare una sequenza logica di eventi!
test "$(git diff --name-only | wc -l)" -eq 3 || file -f .git/candle-changed && touch .git/candle-changed
2021-09-14 17:03:17 +02:00
# Aggiungi solo uno dei cambiamenti!
test "$(git diff --cached --name-only | wc -l)" -eq 1 || file -f .git/candle-added && touch .git/candle-added
2021-09-14 17:03:17 +02:00
# E fai un commit
COUNT=0
for commit in $(git cat-file --batch-check='%(objectname) %(objecttype)' --batch-all-objects | grep 'commit$' | cut -f1 -d' '); do
if test "$(git diff --name-only $commit $commit^ | wc -l)" -eq 1; then
COUNT=$((COUNT+1))
fi
done
test "$COUNT" -ge 1
2021-09-14 17:03:17 +02:00
# Fai un secondo commit che registri solo un singolo cambiamento.
COUNT=0
for commit in $(git cat-file --batch-check='%(objectname) %(objecttype)' --batch-all-objects | grep 'commit$' | cut -f1 -d' '); do
if test "$(git diff --name-only $commit $commit^ | wc -l)" -eq 1; then
COUNT=$((COUNT+1))
fi
done
test "$COUNT" -ge 2
2021-09-14 17:03:17 +02:00
# E aggiungine un terzo.
COUNT=0
for commit in $(git cat-file --batch-check='%(objectname) %(objecttype)' --batch-all-objects | grep 'commit$' | cut -f1 -d' '); do
if test "$(git diff --name-only $commit $commit^ | wc -l)" -eq 1; then
COUNT=$((COUNT+1))
fi
done
test "$COUNT" -ge 3