Skip to content

Commit c35f0dc

Browse files
[hp-view-commits] Implement hands on hp-view-commits (#104)
# Exercise Review ## Exercise Discussion #90 ## 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 512e20c commit c35f0dc

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

hands_on/view_commits.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import os
2+
3+
from exercise_utils.file import append_to_file, create_or_update_file
4+
from exercise_utils.git import add, commit, init
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+
14+
init(verbose)
15+
16+
create_or_update_file(
17+
"fruits.txt",
18+
"""
19+
apples
20+
bananas
21+
cherries
22+
dragon fruits
23+
""",
24+
)
25+
26+
add(["fruits.txt"], verbose)
27+
commit("Add fruits.txt", verbose)
28+
29+
append_to_file(
30+
"fruits.txt",
31+
"""
32+
elderberries
33+
figs
34+
""",
35+
)
36+
add(["fruits.txt"], verbose)
37+
commit("Add elderberries and figs into fruits.txt", verbose)
38+
39+
create_or_update_file(
40+
"colours.txt",
41+
"""
42+
a file for colours
43+
""",
44+
)
45+
create_or_update_file(
46+
"shapes.txt",
47+
"""
48+
a file for shapes
49+
""",
50+
)
51+
add(["colours.txt", "shapes.txt"], verbose)
52+
commit("Add colours.txt, shapes.txt", verbose)
53+
54+
create_or_update_file(
55+
"fruits.txt",
56+
"""
57+
apples, apricots
58+
bananas
59+
blueberries
60+
cherries
61+
dragon fruits
62+
figs
63+
""",
64+
)
65+
add(["fruits.txt"], verbose)
66+
commit("Update fruits list", verbose)
67+

0 commit comments

Comments
 (0)