Skip to content

Commit ccb5c09

Browse files
jiaxinnnsjiaxin
andauthored
[branch-previous] Implement exercise T6L1/branch-previous (#125)
# Exercise Review ## Exercise Discussion Fixes #65 ## 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? - [X] 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)? --------- Co-authored-by: jiaxin <[email protected]>
1 parent 4926424 commit ccb5c09

15 files changed

+629
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"exercise_name": "branch-previous",
3+
"tags": [
4+
"git-branch"
5+
],
6+
"requires_git": true,
7+
"requires_github": false,
8+
"base_files": {},
9+
"exercise_repo": {
10+
"repo_type": "local",
11+
"repo_name": "horror-story",
12+
"repo_title": null,
13+
"create_fork": null,
14+
"init": true
15+
}
16+
}

branch_previous/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
See https://git-mastery.github.io/lessons/branch/exercise-branch-previous.html

branch_previous/__init__.py

Whitespace-only changes.

branch_previous/download.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from exercise_utils.file import create_or_update_file, append_to_file
2+
from exercise_utils.git import add, commit
3+
4+
def setup(verbose: bool = False):
5+
create_or_update_file(
6+
"story.txt",
7+
"""
8+
It was a dark and stormy night.
9+
"""
10+
)
11+
add(["story.txt"], verbose)
12+
commit("Describe night", verbose)
13+
14+
append_to_file(
15+
"story.txt",
16+
"""
17+
I was alone in my room.
18+
"""
19+
)
20+
add(["story.txt"], verbose)
21+
commit("Describe location", verbose)
22+
23+
append_to_file(
24+
"story.txt",
25+
"""
26+
I heard a strange noise.
27+
"""
28+
)
29+
add(["story.txt"], verbose)
30+
commit("Mention noise", verbose)

branch_previous/tests/__init__.py

Whitespace-only changes.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
initialization:
2+
steps:
3+
- type: new-file
4+
filename: story.txt
5+
contents: "It was a dark and stormy night.\n"
6+
- type: add
7+
files:
8+
- story.txt
9+
- type: commit
10+
message: Describe night
11+
id: start
12+
- type: append-file
13+
filename: story.txt
14+
contents: "I was alone in my room.\n"
15+
- type: add
16+
files:
17+
- story.txt
18+
- type: commit
19+
message: Describe location
20+
empty: false
21+
- type: append-file
22+
filename: story.txt
23+
contents: "I heard a strange noise.\n"
24+
- type: add
25+
files:
26+
- story.txt
27+
- type: commit
28+
message: Mention noise
29+
empty: false
30+
- type: checkout
31+
branch-name: visitor-line
32+
start-point: HEAD~1
33+
- type: append-file
34+
filename: story.txt
35+
contents: "I heard someone knocking at the door.\n"
36+
- type: add
37+
files:
38+
- story.txt
39+
- type: commit
40+
message: Mention knocking
41+
empty: false
42+
- type: checkout
43+
branch-name: sleep-line
44+
start-point: HEAD~1
45+
- type: append-file
46+
filename: story.txt
47+
contents: "I fell asleep on the couch.\n"
48+
- type: add
49+
files:
50+
- story.txt
51+
- type: commit
52+
message: Mention sleeping
53+
empty: false
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
initialization:
2+
steps:
3+
- type: new-file
4+
filename: story.txt
5+
contents: "It was a dark and stormy night.\n"
6+
- type: add
7+
files:
8+
- story.txt
9+
- type: commit
10+
message: Describe night
11+
empty: false
12+
id: start
13+
- type: append-file
14+
filename: story.txt
15+
contents: "I was alone in my room.\n"
16+
- type: add
17+
files:
18+
- story.txt
19+
- type: commit
20+
message: Describe location
21+
empty: false
22+
- type: append-file
23+
filename: story.txt
24+
contents: "I heard a strange noise.\n"
25+
- type: add
26+
files:
27+
- story.txt
28+
- type: commit
29+
message: Mention noise
30+
empty: false
31+
# Only create visitor-line branch, not sleep-line
32+
- type: checkout
33+
branch-name: visitor-line
34+
start-point: HEAD~1
35+
- type: append-file
36+
filename: story.txt
37+
contents: "I heard someone knocking at the door.\n"
38+
- type: add
39+
files:
40+
- story.txt
41+
- type: commit
42+
message: Mention knocking
43+
empty: false
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
initialization:
2+
steps:
3+
- type: new-file
4+
filename: story.txt
5+
contents: "It was a dark and stormy night.\n"
6+
- type: add
7+
files:
8+
- story.txt
9+
- type: commit
10+
message: Describe night
11+
empty: false
12+
id: start
13+
- type: append-file
14+
filename: story.txt
15+
contents: "I was alone in my room.\n"
16+
- type: add
17+
files:
18+
- story.txt
19+
- type: commit
20+
message: Describe location
21+
empty: false
22+
- type: append-file
23+
filename: story.txt
24+
contents: "I heard a strange noise.\n"
25+
- type: add
26+
files:
27+
- story.txt
28+
- type: commit
29+
message: Mention noise
30+
empty: false
31+
- type: checkout
32+
branch-name: visitor-line
33+
start-point: HEAD~1
34+
- type: append-file
35+
filename: story.txt
36+
contents: "I heard someone knocking at the door.\n"
37+
- type: add
38+
files:
39+
- story.txt
40+
- type: commit
41+
message: Mention knocking
42+
empty: false
43+
- type: checkout
44+
branch-name: sleep-line
45+
start-point: HEAD~1
46+
- type: append-file
47+
filename: story.txt
48+
contents: "Wrong content here.\n"
49+
- type: add
50+
files:
51+
- story.txt
52+
- type: commit
53+
message: Mention sleeping
54+
empty: false
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
initialization:
2+
steps:
3+
- type: new-file
4+
filename: story.txt
5+
contents: "It was a dark and stormy night.\n"
6+
- type: add
7+
files:
8+
- story.txt
9+
- type: commit
10+
message: Describe night
11+
id: start
12+
- type: append-file
13+
filename: story.txt
14+
contents: "I was alone in my room.\n"
15+
- type: add
16+
files:
17+
- story.txt
18+
- type: commit
19+
message: Describe location
20+
empty: false
21+
- type: append-file
22+
filename: story.txt
23+
contents: "I heard a strange noise.\n"
24+
- type: add
25+
files:
26+
- story.txt
27+
- type: commit
28+
message: Mention noise
29+
empty: false
30+
# Only create sleep-line branch, not visitor-line
31+
- type: checkout
32+
branch-name: sleep-line
33+
start-point: HEAD~1
34+
- type: append-file
35+
filename: story.txt
36+
contents: "I fell asleep on the couch.\n"
37+
- type: add
38+
files:
39+
- story.txt
40+
- type: commit
41+
message: Mention sleeping
42+
empty: false
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
initialization:
2+
steps:
3+
- type: new-file
4+
filename: story.txt
5+
contents: "It was a dark and stormy night.\n"
6+
- type: add
7+
files:
8+
- story.txt
9+
- type: commit
10+
message: Describe night
11+
empty: false
12+
id: start
13+
- type: append-file
14+
filename: story.txt
15+
contents: "I was alone in my room.\n"
16+
- type: add
17+
files:
18+
- story.txt
19+
- type: commit
20+
message: Describe location
21+
empty: false
22+
- type: append-file
23+
filename: story.txt
24+
contents: "I heard a strange noise.\n"
25+
- type: add
26+
files:
27+
- story.txt
28+
- type: commit
29+
message: Mention noise
30+
empty: false
31+
# visitor-line branch created but no commit made
32+
- type: checkout
33+
branch-name: visitor-line
34+
start-point: HEAD~1
35+
# sleep-line branch created with commit
36+
- type: checkout
37+
branch-name: sleep-line
38+
start-point: HEAD
39+
- type: append-file
40+
filename: story.txt
41+
contents: "I fell asleep on the couch.\n"
42+
- type: add
43+
files:
44+
- story.txt
45+
- type: commit
46+
message: Mention sleeping
47+
empty: false

0 commit comments

Comments
 (0)