forked from C2SM/git-course
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.sh
executable file
·120 lines (94 loc) · 2.56 KB
/
helpers.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
if [[ ! -z $dir_at_startup ]]; then
echo "You cannot source this file twice"
else
dir_at_startup=$(pwd)
fi
reset () {
echo "Go back to $dir_at_startup"
cd $dir_at_startup
echo "Restore clean working directory"
mkdir -p work
rm -rf work
mkdir work
cd work
echo "Here we go again!"
}
init_exercise () {
cd $dir_at_startup
mkdir -p work
cd work
echo "Working directory prepared"
}
init_empty_folder () {
mkdir -p party_planning
cd party_planning
touch partyplan.txt
}
init_simple_repo () {
mkdir -p party_planning
cd party_planning
git init
cp ../../examples/flyer_A .
cp ../../examples/flyer_B .
git add flyer_A && git commit -m "add flyer_A"
git add flyer_B && git commit -m "add flyer_B"
echo "Doors: 22:00" >> flyer_A
echo "Doors: 21:00" >> flyer_B
git add * && git commit -m "add opening time"
echo "Happy Hour: 23:00 - 24:00" >> flyer_A
echo "Happy Hour: 22:00 - 24:00" >> flyer_B
git add * && git commit -m "add happy-hour"
echo ""
echo "Your commits so far:"
echo ""
git log
echo""
echo "Your flyers:"
echo""
ls
}
init_simple_repo_remote () {
mkdir -p party_planning
cd party_planning
git init
cp ../../examples/flyer_A .
cp ../../examples/flyer_B .
git add flyer_A && git commit -m "add flyer_A"
git add flyer_B && git commit -m "add flyer_B"
echo "Doors: 22:00" >> flyer_A
echo "Doors: 21:00" >> flyer_B
git add * && git commit -m "add opening time"
echo "Happy Hour: 23:00 - 24:00" >> flyer_A
echo "Happy Hour: 22:00 - 24:00" >> flyer_B
git add * && git commit -m "add happy-hour"
cd ..
git clone party_planning party_planning_remote
cd party_planning_remote
git checkout -b "updated_flyers"
echo "Happy Hour: 17:00 - 18:00" >> flyer_A
echo "Happy Hour: 26:00 - 18:00" >> flyer_B
git add * && git commit -m "update the flyers"
git checkout master
cd ../party_planning
ls
}
init_broken_repo () {
init_simple_repo &> /dev/null
echo "Music: Heavy Metal" >> flyer_A
echo "Music: Heavy Metal" >> flyer_B
git add * && git commit -m "Metal Music added"
sed 's/Heavy Metal/Classical Music/g' flyer_A > flyer_A_tmp
sed 's/Heavy Metal/Classical Music/g' flyer_B > flyer_B_tmp
mv flyer_A_tmp flyer_A
mv flyer_B_tmp flyer_B
git add * && git commit -m "Classical Music added"
echo ""
echo "Your commits so far:"
echo ""
git log
echo""
echo "Your flyers:"
echo""
ls
}