Skip to content

Commit 13f2bf5

Browse files
authored
Implement L2 exercise: mix-messy-graph (#73)
# Exercise Review ## Exercise Discussion #71 ## 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? - [ ] Have you tested the download script using `test-download.sh`? - [ ] 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)?
2 parents ccca7a1 + 22f7a81 commit 13f2bf5

13 files changed

+470
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"exercise_name": "mix-messy-graph",
3+
"tags": [
4+
"git-branch",
5+
"git-merge"
6+
],
7+
"requires_git": true,
8+
"requires_github": true,
9+
"base_files": {},
10+
"exercise_repo": {
11+
"repo_type": "remote",
12+
"repo_name": "user-docs",
13+
"repo_title": "gm-user-docs",
14+
"create_fork": false,
15+
"init": null
16+
}
17+
}

mix_messy_graph/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# mix-messy-graph
2+
3+
You are writing user documentation for a product. You have already written documentation for a few new features, each in a separate branch. After merging the `feature-search` branch, you realise this way of merging can result in a complicated revision graph. Instead, you wish to merge these changes in a way that results in a simple linear revision graph.
4+
5+
## Task
6+
7+
1. Undo the merging of `feature-search`.
8+
2. Squash-merge the `feature-search` branch onto the `main` branch. Delete the `feature-search` branch.
9+
3. Similarly, squash-merge and delete the `feature-delete` branch, while resolving any merge conflicts -- in the `features.md`, the delete feature should appear after the search feature.
10+
4. The `list` branch is not needed, as you have decided not to have that feature. Delete that branch.
11+
12+
The resulting revision graph should be as follows:
13+
14+
```mermaid
15+
gitGraph BT:
16+
commit id: "Add features.md"
17+
commit id: "Mention feature for creating books" tag: "v10"
18+
commit id: "Add the delete feature"
19+
commit id: "Add the search feature"
20+
```

mix_messy_graph/__init__.py

Whitespace-only changes.

mix_messy_graph/download.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from exercise_utils.git import merge, merge_with_message, track_remote_branch
2+
3+
4+
def setup(verbose: bool = False):
5+
remote_name = "origin"
6+
remote_branches = ["feature-search", "feature-delete", "list"]
7+
for remote_branch_name in remote_branches:
8+
track_remote_branch(remote_name, remote_branch_name, verbose)
9+
10+
merge_with_message("feature-search", False, "Merge search feature", verbose)

mix_messy_graph/tests/__init__.py

Whitespace-only changes.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
initialization:
2+
steps:
3+
- type: commit
4+
empty: true
5+
message: Add features.md
6+
id: start
7+
- type: commit
8+
empty: true
9+
message: Mention feature for creating books
10+
- type: tag
11+
tag-name: v1.0
12+
- type: commit
13+
empty: true
14+
message: Fix phrasing of heading
15+
16+
- type: commit
17+
empty: true
18+
message: Add the search feature
19+
20+
- type: commit
21+
empty: true
22+
message: Add the delete feature
23+
24+
- type: new-file
25+
filename: features.md
26+
contents: |
27+
# Features
28+
29+
## Create Book
30+
31+
Allows creating one book at a time.
32+
33+
## Searching for Books
34+
35+
Allows searching for books by keywords.
36+
Works only for book titles.
37+
38+
## Deleting Books
39+
40+
Allows deleting books.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
initialization:
2+
steps:
3+
- type: commit
4+
empty: true
5+
message: Add features.md
6+
id: start
7+
- type: commit
8+
empty: true
9+
message: Mention feature for creating books
10+
- type: tag
11+
tag-name: v1.0
12+
- type: commit
13+
empty: true
14+
message: Fix phrasing of heading
15+
16+
- type: commit
17+
empty: true
18+
message: Add the search feature
19+
20+
- type: commit
21+
empty: true
22+
message: Add the delete feature
23+
24+
- type: branch
25+
branch-name: feature-search
26+
- type: checkout
27+
branch-name: main
28+
- type: branch
29+
branch-name: feature-delete
30+
- type: checkout
31+
branch-name: main
32+
- type: branch
33+
branch-name: list
34+
35+
- type: new-file
36+
filename: features.md
37+
contents: |
38+
# Features
39+
40+
## Create Book
41+
42+
Allows creating one book at a time.
43+
44+
## Searching for Books
45+
46+
Allows searching for books by keywords.
47+
Works only for book titles.
48+
49+
## Deleting Books
50+
51+
Allows deleting books.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
initialization:
2+
steps:
3+
- type: commit
4+
empty: true
5+
message: Add features.md
6+
id: start
7+
- type: commit
8+
empty: true
9+
message: Mention feature for creating books
10+
- type: tag
11+
tag-name: v1.0
12+
- type: commit
13+
empty: true
14+
message: Fix phrasing of heading
15+
16+
- type: commit
17+
empty: true
18+
message: Add the search feature
19+
20+
- type: commit
21+
empty: true
22+
message: Add the delete feature
23+
24+
- type: new-file
25+
filename: features.md
26+
contents: |
27+
# Features
28+
29+
## Searching for Books
30+
31+
Allows searching for books by keywords.
32+
Works only for book titles.
33+
34+
## Create Book
35+
36+
Allows creating one book at a time.
37+
38+
## Deleting Books
39+
40+
Allows deleting books.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
initialization:
2+
steps:
3+
- type: commit
4+
empty: true
5+
message: Add features.md
6+
id: start
7+
- type: commit
8+
empty: true
9+
message: Mention feature for creating books
10+
- type: tag
11+
tag-name: v1.0
12+
- type: commit
13+
empty: true
14+
message: Fix phrasing of heading
15+
16+
- type: commit
17+
empty: true
18+
message: Add the search feature
19+
20+
- type: new-file
21+
filename: features.md
22+
contents: |
23+
# Features
24+
25+
## Create Book
26+
27+
Allows creating one book at a time.
28+
29+
## Searching for Books
30+
31+
Allows searching for books by keywords.
32+
Works only for book titles.
33+
34+
## Deleting Books
35+
36+
Allows deleting books.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
initialization:
2+
steps:
3+
- type: commit
4+
empty: true
5+
message: Add features.md
6+
id: start
7+
- type: commit
8+
empty: true
9+
message: Mention feature for creating books
10+
- type: tag
11+
tag-name: v1.0
12+
- type: commit
13+
empty: true
14+
message: Fix phrasing of heading
15+
16+
- type: branch
17+
branch-name: feature-search
18+
- type: commit
19+
empty: true
20+
message: Feature search
21+
- type: checkout
22+
branch-name: main
23+
- type: merge
24+
branch-name: feature-search
25+
26+
- type: commit
27+
empty: true
28+
message: Add the delete feature
29+
30+
- type: new-file
31+
filename: features.md
32+
contents: |
33+
# Features
34+
35+
## Create Book
36+
37+
Allows creating one book at a time.
38+
39+
## Searching for Books
40+
41+
Allows searching for books by keywords.
42+
Works only for book titles.
43+
44+
## Deleting Books
45+
46+
Allows deleting books.

0 commit comments

Comments
 (0)