Skip to content

Commit 2f71799

Browse files
vanphuc1201jovnc
andauthored
[ff-undo] Implement exercise T6L2/ff-undo (#101)
# Exercise Review ## Exercise Discussion #89 ## 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: jovnc <[email protected]>
1 parent acc944a commit 2f71799

File tree

12 files changed

+269
-0
lines changed

12 files changed

+269
-0
lines changed

ff_undo/.gitmastery-exercise.json

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

ff_undo/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/merge/exercise-ff-undo.html

ff_undo/__init__.py

Whitespace-only changes.

ff_undo/download.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
from exercise_utils.git import (
2+
add,
3+
commit,
4+
checkout,
5+
merge,
6+
)
7+
from exercise_utils.file import (
8+
create_or_update_file,
9+
append_to_file,
10+
)
11+
12+
13+
def setup(verbose: bool = False):
14+
create_or_update_file(
15+
"rick.txt",
16+
"""
17+
Hero
18+
""",
19+
)
20+
add(["."], verbose)
21+
commit("Add Rick", verbose)
22+
23+
create_or_update_file(
24+
"morty.txt",
25+
"""
26+
Boy
27+
""",
28+
)
29+
add(["."], verbose)
30+
commit("Add Morty", verbose)
31+
32+
checkout("others", True, verbose)
33+
34+
create_or_update_file(
35+
"birdperson.txt",
36+
"""
37+
No job
38+
""",
39+
)
40+
add(["."], verbose)
41+
commit("Add Birdperson", verbose)
42+
43+
append_to_file(
44+
"birdperson.txt",
45+
"""
46+
Cyborg
47+
""",
48+
)
49+
add(["."], verbose)
50+
commit("Add Cyborg to birdperson.txt", verbose)
51+
52+
create_or_update_file(
53+
"tammy.txt",
54+
"""
55+
Spy
56+
""",
57+
)
58+
add(["."], verbose)
59+
commit("Add Tammy", verbose)
60+
61+
checkout("main", False, verbose)
62+
merge("others", True, verbose)

ff_undo/tests/__init__.py

Whitespace-only changes.

ff_undo/tests/specs/base.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
initialization:
2+
steps:
3+
- type: commit
4+
empty: true
5+
message: Set initial state
6+
id: start
7+
- type: commit
8+
message: "Add Rick"
9+
- type: commit
10+
message: "Add Morty"
11+
- type: branch
12+
branch-name: others
13+
- type: checkout
14+
branch-name: others
15+
- type: commit
16+
message: "Add Birdperson"
17+
- type: commit
18+
message: "Add Cyborg to birdperson.txt"
19+
- type: commit
20+
message: "Add Tammy"
21+
- type: checkout
22+
branch-name: main
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
initialization:
2+
steps:
3+
- type: commit
4+
empty: true
5+
message: Set initial state
6+
id: start
7+
- type: commit
8+
message: "Add Rick"
9+
- type: commit
10+
message: "Add Morty"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
initialization:
2+
steps:
3+
- type: commit
4+
empty: true
5+
message: Set initial state
6+
id: start
7+
- type: commit
8+
message: "Add Morty"
9+
- type: branch
10+
branch-name: others
11+
- type: checkout
12+
branch-name: others
13+
- type: commit
14+
message: "Add Birdperson"
15+
- type: commit
16+
message: "Add Cyborg to birdperson.txt"
17+
- type: commit
18+
message: "Add Tammy"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
initialization:
2+
steps:
3+
- type: commit
4+
empty: true
5+
message: Set initial state
6+
id: start
7+
- type: commit
8+
message: "Add Rick"
9+
- type: commit
10+
message: "Add Morty"
11+
- type: branch
12+
branch-name: others
13+
- type: checkout
14+
branch-name: others
15+
- type: commit
16+
message: "Add Birdperson"
17+
- type: commit
18+
message: "Add Cyborg to birdperson.txt"
19+
- type: commit
20+
message: "Add Tammy"
21+
- type: checkout
22+
branch-name: main
23+
- type: merge
24+
branch-name: others
25+
no-ff: false
26+
message: "Introduce others"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
initialization:
2+
steps:
3+
- type: commit
4+
empty: true
5+
message: Set initial state
6+
id: start
7+
- type: commit
8+
message: "Add Rick"
9+
- type: commit
10+
message: "Add Morty"
11+
- type: branch
12+
branch-name: others
13+
- type: checkout
14+
branch-name: others
15+
- type: commit
16+
message: "Add Birdperson"
17+
- type: commit
18+
message: "Add Tammy"

0 commit comments

Comments
 (0)