oh-my-git/levels/changing-the-past/reorder
Ben Donatelli 5b12679988 Make reorder level winnable on macOS platforms by using perl instead of grep
macOS provides BSD grep which does not support -P flag. Perl pattern match
works on all platforms.

Fixes git-learning-game/oh-my-git#79
2021-03-26 20:38:15 -05:00

79 lines
1.7 KiB
Plaintext

title = Reordering events
cards = checkout commit-auto reset-hard rebase-interactive cherry-pick
[description]
Oops, looks like there's something messed up here. Can you put the events back into their correct order?
There are two ways to do this: You can drag the "interactive rebase" card to the commit before the one you want to change, then reorder the lines in the file that opens, and save it.
Or you can reset the main tag to the very first commit, and then cherry-pick single commits in the order you want. You have cards for both approaches!
[setup]
echo "You just woke up.
You are NOT wearing underwear.
You are NOT wearing pants.
You are NOT wearing a shirt.
You are NOT wearing shoes." > you
git add .
git commit -m "The Beginning"
echo "You just woke up.
You are NOT wearing underwear.
You are NOT wearing pants.
You are NOT wearing a shirt.
You are wearing shoes." > you
git commit -am "Put on shoes"
echo "You just woke up.
You are NOT wearing underwear.
You are wearing pants.
You are NOT wearing a shirt.
You are wearing shoes." > you
git commit -am "Put on pants"
echo "You just woke up.
You are wearing underwear.
You are wearing pants.
You are NOT wearing a shirt.
You are wearing shoes." > you
git commit -am "Put on underwear"
echo "You just woke up.
You are wearing underwear.
You are wearing pants.
You are wearing a shirt.
You are wearing shoes." > you
git commit -am "Put on shirt"
[win]
# Reorder the commits to dress yourself in the correct way
{ git log main --oneline | perl -0777 -ne'exit(1) if not /shoes[\s\S]*pants[\s\S]*underwear/'; } && { test "$(git log main --oneline | wc -l)" -eq 5; }
[congrats]
Feel free to reset the level and try the other strategy! Which one do you like better?