Skip to content

Commit 5fb32eb

Browse files
authored
[hp-diff-changes] Implement hands on hp-diff-changes (#112)
# Exercise Review ## Exercise Discussion Link the exercise discussion issue #105 ## Checklist - [ ] If you require a new remote repository on the `Git-Mastery` organization, have you [created a request](https://github.com/git-mastery/exercises/issues/new?template=request_exercise_repository.md) for it? - [ ] Have you written unit tests using [`repo-smith`](https://github.com/git-mastery/repo-smith) to validate the exercise grading scheme? - [X] Have you tested the download script using `test-download.sh`? - [X] Have you verified that this exercise does not already exist or is not currently in review? - [ ] Did you introduce a new grading mechanism that should belong to [`git-autograder`](https://github.com/git-mastery/git-autograder)? - [ ] Did you introduce a new dependency that should belong to [`app`](https://github.com/git-mastery/app)?
1 parent c35f0dc commit 5fb32eb

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

hands_on/diff_changes.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import os
2+
3+
from exercise_utils.file import create_or_update_file, append_to_file
4+
from exercise_utils.git import add, init, commit, tag
5+
6+
__requires_git__ = True
7+
__requires_github__ = False
8+
9+
10+
def download(verbose: bool):
11+
os.makedirs("things")
12+
os.chdir("things")
13+
init(verbose)
14+
create_or_update_file(
15+
"fruits.txt",
16+
"""
17+
apples
18+
bananas
19+
cherries
20+
dragon fruits
21+
""",
22+
)
23+
add(["fruits.txt"], verbose)
24+
commit("Add fruits.txt", verbose)
25+
append_to_file("fruits.txt",
26+
"""
27+
elderberries
28+
figs
29+
"""
30+
)
31+
add(["fruits.txt"], verbose)
32+
commit("Add elderberries and figs to fruits.txt", verbose)
33+
34+
create_or_update_file(
35+
"colours.txt",
36+
"a file for colours\n",
37+
)
38+
create_or_update_file(
39+
"shapes.txt",
40+
"a file for shapes\n",
41+
)
42+
add(["colours.txt", "shapes.txt"], verbose)
43+
commit("Add colours.txt, shapes.txt", verbose)
44+
45+
tag("v0.9", verbose)
46+
47+
# Replace the whole contents of fruits.txt
48+
create_or_update_file("fruits.txt",
49+
"""
50+
apples, apricots
51+
bananas
52+
blueberries
53+
cherries
54+
dragon fruits
55+
figs
56+
"""
57+
)
58+
add(["fruits.txt"], verbose)
59+
commit("Update fruits list", verbose)
60+
61+
append_to_file("colours.txt",
62+
"""
63+
blue
64+
red
65+
white
66+
"""
67+
)
68+
add(["colours.txt"], verbose)
69+
commit("colours.txt: Add some colours", verbose)
70+
71+
append_to_file("shapes.txt",
72+
"""
73+
circle
74+
oval
75+
rectangle
76+
square
77+
"""
78+
)
79+
add(["shapes.txt"], verbose)
80+
commit("shapes.txt: Add some shapes", verbose)

0 commit comments

Comments
 (0)