-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sh
executable file
·170 lines (135 loc) · 2.88 KB
/
init.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/usr/bin/env sh
if [ -z $1 ]
then
CURR=$(basename $(pwd))
cd ..
else
CURR=$1
fi
case $CURR in
1*|01*)
if cd 01-*
then
rm -rf * .git
else
echo "Could not find a directory beginning with 01-"
exit 1
fi
git init
echo "I'm a text file!" > hello.txt
chmod 755 hello.txt
git add hello.txt
git commit -m "Inital commit"
echo "With ~style~" >> hello.txt
exit 0
;;
2*|02*)
if cd 02-*
then
rm -rf * .git
else
echo "Could not find a directory beginning with 02-"
exit 1
fi
echo "I'm a text file!" > hello.txt
git init
chmod 755 hello.txt
git add hello.txt
git commit -m "Inital commit"
exit 0
;;
3*|03*)
if cd 03-*
then
rm -rf * .git
else
echo "Could not find a directory beginning with 03-"
exit 1
fi
echo "I'm a text file!" > hello.txt
git init
chmod 755 hello.txt
git add hello.txt
git commit -m "Inital commit"
echo "A new line" >> hello.txt
git add hello.txt
git commit -m "Did the thing... WAIT!"
echo "And another new line" >> hello.txt
exit 0
;;
4*|04*)
if cd 04-*
then
rm -rf * .git
else
echo "Could not find a directory beginning with 04-"
exit 1
fi
echo "I'm a text file!" > hello.txt
git init
chmod 755 hello.txt
git add hello.txt
git commit -m "Inital commit"
git branch -m "get-away-from-me"
exit 0
;;
5*|05*)
if cd 05-*
then
rm -rf * .git
else
echo "Could not find a directory beginning with 05-"
exit 1
fi
echo "def f(): pass # Not implemented" > code.py
echo >> code.py
echo "print(f())" >> code.py
git init
git checkout -b master
chmod 755 code.py
git add code.py
git commit -m "Inital commit"
git checkout -b "implement-f"
echo "def f(): return 42" > code.py
echo >> code.py
echo "print(f())" >> code.py
git commit code.py -m "Implement f"
git checkout master
exit 0
;;
6*|06*)
if cd 06-*
then
rm -rf * .git
else
echo "Could not find a directory beginning with 06-"
exit 1
fi
echo "def f(): return 1" > code.py
echo >> code.py
echo "print(f())" >> code.py
git init
git checkout -b master
chmod 755 code.py
git add code.py
git commit -m "Inital commit"
git checkout -b implement-g
echo >> code.py
echo "def g(): return 2" > code.py
echo >> code.py
echo "print(g())" >> code.py
git commit code.py -m "Implement g"
git checkout master
echo >> code.py
echo "def h(): return 3" > code.py
echo >> code.py
echo "print(h())" >> code.py
git commit code.py -m "Implement h"
git merge implement-g
exit 0
;;
esac
echo "Don't know what task that is..."
echo "Possible exercises:"
ls .
exit 1