Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions merge_squash/.gitmastery-exercise.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"exercise_name": "merge-squash",
"tags": [
"git-branch",
"git-merge",
"git-reset"
],
"requires_git": true,
"requires_github": false,
"base_files": {},
"exercise_repo": {
"repo_type": "local",
"repo_name": "friends-cast",
"repo_title": null,
"create_fork": null,
"init": true
}
}
40 changes: 40 additions & 0 deletions merge_squash/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# merge-squash

You are keeping notes on the cast of a sitcom you've started watching. Initially, you kept main cast and supporting cast on two separate branches.

```mermaid
gitGraph BT:
commit id: "Add Joey"
commit id: "Add Phoebe"
branch supporting
checkout supporting
commit id: "Add Mike"
commit id: "Add Janice"
checkout main
commit id: "Add Ross"
```

Now you wish to keep everything in the `main` branch.

## Task

Squash-merge the `supporting` branch onto the `main` branch.

The result should look as follows:

```mermaid
gitGraph BT:
commit id: "Add Joey"
commit id: "Add Phoebe"
branch supporting
checkout supporting
commit id: "Add Mike"
commit id: "Add Janice"
checkout main
commit id: "Add Ross"
commit id: "Squash commit"
```

## Hints

You have to commit manually after performing the squash merge.
Empty file added merge_squash/__init__.py
Empty file.
51 changes: 51 additions & 0 deletions merge_squash/download.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from exercise_utils.file import create_or_update_file
from exercise_utils.git import add, commit, checkout


def setup(verbose: bool = False):
create_or_update_file(
"joey.txt",
"""
Matt LeBlanc
""",
)
add(["."], verbose)
commit("Add Joey", verbose)

create_or_update_file(
"phoebe.txt",
"""
Lisa Kudrow
""",
)
add(["."], verbose)
commit("Add Phoebe", verbose)

checkout("supporting", True, verbose)
create_or_update_file(
"mike.txt",
"""
Paul Rudd
""",
)
add(["."], verbose)
commit("Add Mike", verbose)

create_or_update_file(
"janice.txt",
"""
Maggie Wheeler
""",
)
add(["."], verbose)
commit("Add Janice", verbose)

checkout("main", False, verbose)
create_or_update_file(
"ross.txt",
"""
David Schwimmer
""",
)
add(["."], verbose)
commit("Add Ross", verbose)
Empty file added merge_squash/tests/__init__.py
Empty file.
67 changes: 67 additions & 0 deletions merge_squash/tests/specs/base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
initialization:
steps:
- type: commit
empty: true
message: Set initial state
id: start
- type: new-file
filename: joey.txt
contents: |
Matt LeBlanc
- type: add
files:
- joey.txt
- type: commit
message: Add Joey

- type: new-file
filename: phoebe.txt
contents: |
Lisa Kudrow
- type: add
files:
- phoebe.txt
- type: commit
message: Add Phoebe

- type: branch
branch-name: supporting
- type: checkout
branch-name: supporting

- type: new-file
filename: mike.txt
contents: |
Paul Rudd
- type: add
files:
- mike.txt
- type: commit
message: Add Mike

- type: new-file
filename: janice.txt
contents: |
Maggie Wheeler
- type: add
files:
- janice.txt
- type: commit
message: Add Janice

- type: checkout
branch-name: main

- type: new-file
filename: ross.txt
contents: |
David Schwimmer
- type: add
files:
- ross.txt
- type: commit
message: Add Ross

- type: merge
squash: true
branch-name: supporting
60 changes: 60 additions & 0 deletions merge_squash/tests/specs/missing_main_commits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
initialization:
steps:
- type: commit
empty: true
message: Set initial state
id: start
- type: new-file
filename: joey.txt
contents: |
Matt LeBlanc
- type: add
files:
- joey.txt
- type: commit
message: Add Joey

- type: branch
branch-name: supporting
- type: checkout
branch-name: supporting

- type: new-file
filename: mike.txt
contents: |
Paul Rudd
- type: add
files:
- mike.txt
- type: commit
message: Add Mike

- type: new-file
filename: janice.txt
contents: |
Maggie Wheeler
- type: add
files:
- janice.txt
- type: commit
message: Add Janice

- type: checkout
branch-name: main

- type: new-file
filename: ross.txt
contents: |
David Schwimmer
- type: add
files:
- ross.txt
- type: commit
message: Add Ross

- type: merge
branch-name: supporting
squash: true

- type: commit
message: Squash commit
66 changes: 66 additions & 0 deletions merge_squash/tests/specs/non_squash_merge_used.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
initialization:
steps:
- type: commit
empty: true
message: Set initial state
id: start
- type: new-file
filename: joey.txt
contents: |
Matt LeBlanc
- type: add
files:
- joey.txt
- type: commit
message: Add Joey

- type: new-file
filename: phoebe.txt
contents: |
Lisa Kudrow
- type: add
files:
- phoebe.txt
- type: commit
message: Add Phoebe

- type: branch
branch-name: supporting
- type: checkout
branch-name: supporting

- type: new-file
filename: mike.txt
contents: |
Paul Rudd
- type: add
files:
- mike.txt
- type: commit
message: Add Mike

- type: new-file
filename: janice.txt
contents: |
Maggie Wheeler
- type: add
files:
- janice.txt
- type: commit
message: Add Janice

- type: checkout
branch-name: main

- type: new-file
filename: ross.txt
contents: |
David Schwimmer
- type: add
files:
- ross.txt
- type: commit
message: Add Ross

- type: merge
branch-name: supporting
63 changes: 63 additions & 0 deletions merge_squash/tests/specs/not_merged.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
initialization:
steps:
- type: commit
empty: true
message: Set initial state
id: start
- type: new-file
filename: joey.txt
contents: |
Matt LeBlanc
- type: add
files:
- joey.txt
- type: commit
message: Add Joey

- type: new-file
filename: phoebe.txt
contents: |
Lisa Kudrow
- type: add
files:
- phoebe.txt
- type: commit
message: Add Phoebe

- type: branch
branch-name: supporting
- type: checkout
branch-name: supporting

- type: new-file
filename: mike.txt
contents: |
Paul Rudd
- type: add
files:
- mike.txt
- type: commit
message: Add Mike

- type: new-file
filename: janice.txt
contents: |
Maggie Wheeler
- type: add
files:
- janice.txt
- type: commit
message: Add Janice

- type: checkout
branch-name: main

- type: new-file
filename: ross.txt
contents: |
David Schwimmer
- type: add
files:
- ross.txt
- type: commit
message: Add Ross
Loading