-
Notifications
You must be signed in to change notification settings - Fork 25
Implement T6L2 merge undo #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kea-S
wants to merge
6
commits into
git-mastery:main
Choose a base branch
from
kea-S:implement-T6L2-mergeUndo
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bd52f30
Test downloads
kea-S 32d840b
Add verification and base test
kea-S c0ccdc8
Fix verification errors
kea-S 2dd0296
Add remaining verification checks
kea-S 17ca5d3
Merge branch 'main' into implement-T6L2-mergeUndo
kea-S c85a366
Add git graphs
kea-S File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "exercise_name": "merge-undo", | ||
| "tags": [ | ||
| "git-branch", | ||
| "git-merge", | ||
| "git-reset" | ||
| ], | ||
| "requires_git": true, | ||
| "requires_github": false, | ||
| "base_files": {}, | ||
| "exercise_repo": { | ||
| "repo_type": "local", | ||
| "repo_name": "play-characters", | ||
| "repo_title": null, | ||
| "create_fork": null, | ||
| "init": true | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # merge-undo | ||
|
|
||
| Scenario: You are keeping notes on the characters of a play that you are writing. In the main story line (which is in the `main` branch), you introduced two characters, Rick and Morty. You had two other characters in two separate branches `daughter` and `son-in-law`. Just now, you introduced these two characters to the main story line by merging the two branches to the `main` branch. | ||
|
|
||
| ```mermaid | ||
| gitGraph | ||
| commit id: "Add Rick" | ||
| commit id: "Add morty" | ||
| branch daughter | ||
| branch son-in-law | ||
| checkout daughter | ||
| commit id: "Add Beth" | ||
| checkout son-in-law | ||
| commit id: "Add Jerry" | ||
| checkout main | ||
| commit id: "Mention Morty is grandson" | ||
| merge daughter id: "Introduce Beth" | ||
| merge son-in-law id: "Introduce Jerry" | ||
| ``` | ||
|
|
||
| However, now you realise this is premature, and wish to undo that change. | ||
|
|
||
| ## Task | ||
|
|
||
| Undo the merging of branches `son-in-law` and `daughter`. | ||
|
|
||
| The result should be as follows: | ||
|
|
||
| ```mermaid | ||
| gitGraph | ||
| commit id: "Add Rick" | ||
| commit id: "Add morty" | ||
| branch daughter | ||
| branch son-in-law | ||
| checkout daughter | ||
| commit id: "Add Beth" | ||
| checkout son-in-law | ||
| commit id: "Add Jerry" | ||
| checkout main | ||
| commit id: "Mention Morty is grandson" | ||
| ``` |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,68 @@ | ||||
| __resources__ = {"README.md": "README.md"} | ||||
|
|
||||
| from exercise_utils.file import create_or_update_file | ||||
| from exercise_utils.git import add, checkout, commit, merge_with_message | ||||
| from exercise_utils.gitmastery import create_start_tag | ||||
|
|
||||
|
|
||||
| def setup(verbose: bool = False): | ||||
| create_start_tag(verbose) | ||||
|
|
||||
| # main branch | ||||
| checkout("main", False, verbose) | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Not necessary. The default branch should always be |
||||
| create_or_update_file( | ||||
| "rick.txt", | ||||
| """ | ||||
| Scientist | ||||
| """, | ||||
| ) | ||||
| add(["rick.txt"], verbose) | ||||
| commit("Add Rick", verbose) | ||||
| create_or_update_file( | ||||
| "morty.txt", | ||||
| """ | ||||
| Boy | ||||
| """, | ||||
| ) | ||||
| add(["morty.txt"], verbose) | ||||
| commit("Add morty", verbose) | ||||
|
|
||||
| # daughter branch | ||||
| checkout("daughter", True, verbose) | ||||
| create_or_update_file( | ||||
| "beth.txt", | ||||
| """ | ||||
| Vet | ||||
| """, | ||||
| ) | ||||
| add(["beth.txt"], verbose) | ||||
| commit("Add Beth", verbose) | ||||
|
|
||||
| # son-in-law branch | ||||
| checkout("main", False, verbose) # switch to main first | ||||
|
|
||||
| checkout("son-in-law", True, verbose) | ||||
| create_or_update_file( | ||||
| "jerry.txt", | ||||
| """ | ||||
| Salesman | ||||
| """, | ||||
| ) | ||||
| add(["jerry.txt"], verbose) | ||||
| commit("Add Herry", verbose) | ||||
|
|
||||
| # Append morty as a grandson | ||||
| checkout("main", False, verbose) | ||||
| create_or_update_file( | ||||
| "morty.txt", | ||||
| """ | ||||
| Boy | ||||
| Grandson | ||||
| """, | ||||
| ) | ||||
| add(["morty.txt"], verbose) | ||||
| commit("Mention Morty is grandson", verbose) | ||||
|
|
||||
| # Merge daughter and son-in-law to main story | ||||
| merge_with_message("daughter", False, "Introduce Beth", verbose) | ||||
| merge_with_message("son-in-law", False, "Introduce Jerry", verbose) | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not need to be a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # merge-undo | ||
|
|
||
| Scenario: You are keeping notes on the characters of a play that you are writing. In the main story line (which is in the `main` branch), you introduced two characters, Rick and Morty. You had two other characters in two separate branches `daughter` and `son-in-law`. Just now, you introduced these two characters to the main story line by merging the two branches to the `main` branch. | ||
|
|
||
| ```mermaid | ||
| gitGraph | ||
| commit id: "Add Rick" | ||
| commit id: "Add morty" | ||
| branch daughter | ||
| branch son-in-law | ||
| checkout daughter | ||
| commit id: "Add Beth" | ||
| checkout son-in-law | ||
| commit id: "Add Jerry" | ||
| checkout main | ||
| commit id: "Mention Morty is grandson" | ||
| merge daughter id: "Introduce Beth" | ||
| merge son-in-law id: "Introduce Jerry" | ||
| ``` | ||
|
|
||
| However, now you realise this is premature, and wish to undo that change. | ||
|
|
||
| ## Task | ||
|
|
||
| Undo the merging of branches `son-in-law` and `daughter`. | ||
|
|
||
| The result should be as follows: | ||
|
|
||
| ```mermaid | ||
| gitGraph | ||
| commit id: "Add Rick" | ||
| commit id: "Add morty" | ||
| branch daughter | ||
| branch son-in-law | ||
| checkout daughter | ||
| commit id: "Add Beth" | ||
| checkout son-in-law | ||
| commit id: "Add Jerry" | ||
| checkout main | ||
| commit id: "Mention Morty is grandson" | ||
| ``` |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| initialization: | ||
| steps: | ||
| - type: commit | ||
| empty: true | ||
| message: Empty commit | ||
| id: start | ||
|
|
||
| # Add rick.txt and commit | ||
| - type: new-file | ||
| filename: rick.txt | ||
| contents: Scientist | ||
| - type: commit | ||
| message: Add Rick | ||
|
|
||
| # Add morty.txt and commit | ||
| - type: new-file | ||
| filename: morty.txt | ||
| contents: Boy | ||
| - type: commit | ||
| message: Add morty | ||
| id: morty-initial-commit | ||
|
|
||
| # Create 'daughter' branch, add beth.txt and commit | ||
| - type: branch | ||
| branch-name: daughter | ||
| from-commit: morty-initial-commit | ||
| - type: checkout | ||
| branch-name: daughter | ||
| - type: new-file | ||
| filename: beth.txt | ||
| contents: Vet | ||
| - type: commit | ||
| message: Add Beth | ||
|
|
||
| # Create 'son-in-law' branch, add jerry.txt and commit | ||
| - type: checkout | ||
| branch-name: main | ||
| - type: branch | ||
| branch-name: son-in-law | ||
| from-commit: morty-initial-commit | ||
| - type: checkout | ||
| branch-name: son-in-law | ||
| - type: new-file | ||
| filename: jerry.txt | ||
| contents: Salesman | ||
| - type: commit | ||
| message: Add Jerry | ||
|
|
||
| # Checkout back to main, edit morty.txt and commit. | ||
| - type: checkout | ||
| branch-name: main | ||
| - type: edit-file | ||
| filename: morty.txt | ||
| contents: | | ||
| Boy | ||
| Grandson | ||
| - type: commit | ||
| message: Mention Morty is grandson | ||
| id: final-main-commit | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| initialization: | ||
| steps: | ||
| - type: commit | ||
| empty: true | ||
| message: Empty commit | ||
| id: start | ||
| - type: new-file | ||
| filename: rick.txt | ||
| contents: Scientist | ||
| - type: commit | ||
| message: Add Rick | ||
| - type: new-file | ||
| filename: morty.txt | ||
| contents: Boy | ||
| - type: commit | ||
| message: Add morty | ||
| id: morty-initial-commit | ||
| - type: branch | ||
| branch-name: daughter | ||
| from-commit: morty-initial-commit | ||
| - type: checkout | ||
| branch-name: daughter | ||
| - type: new-file | ||
| filename: beth.txt | ||
| contents: Vet | ||
| - type: commit | ||
| message: Add Beth | ||
| - type: checkout | ||
| branch-name: main | ||
| - type: branch | ||
| branch-name: son-in-law | ||
| from-commit: morty-initial-commit | ||
| - type: checkout | ||
| branch-name: son-in-law | ||
| - type: new-file | ||
| filename: jerry.txt | ||
| contents: Salesman | ||
| - type: commit | ||
| message: Add Jerry | ||
| - type: checkout | ||
| branch-name: main | ||
| - type: edit-file | ||
| filename: morty.txt | ||
| contents: | | ||
| Boy | ||
| Grandson | ||
| - type: commit | ||
| message: Mention Morty is grandson | ||
| - type: checkout | ||
| commit-hash: main | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| initialization: | ||
| steps: | ||
| - type: commit | ||
| empty: true | ||
| message: Empty commit | ||
| id: start | ||
| - type: new-file | ||
| filename: rick.txt | ||
| contents: Scientist | ||
| - type: commit | ||
| message: Add Rick | ||
| - type: new-file | ||
| filename: morty.txt | ||
| contents: Boy | ||
| - type: commit | ||
| message: Add morty | ||
| id: morty-initial-commit | ||
| - type: branch | ||
| branch-name: daughter | ||
| from-commit: morty-initial-commit | ||
| - type: checkout | ||
| branch-name: daughter | ||
| - type: new-file | ||
| filename: beth.txt | ||
| contents: Vet | ||
| - type: commit | ||
| message: Add Beth | ||
| - type: checkout | ||
| branch-name: main | ||
| - type: branch | ||
| branch-name: son-in-law | ||
| from-commit: morty-initial-commit | ||
| - type: checkout | ||
| branch-name: son-in-law | ||
| - type: new-file | ||
| filename: jerry.txt | ||
| contents: Salesman | ||
| - type: commit | ||
| message: Add Jerry | ||
| - type: checkout | ||
| branch-name: main | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| initialization: | ||
| steps: | ||
| - type: commit | ||
| empty: true | ||
| message: Empty commit | ||
| id: start | ||
| - type: new-file | ||
| filename: rick.txt | ||
| contents: Scientist | ||
| - type: commit | ||
| message: Add Rick | ||
| - type: new-file | ||
| filename: morty.txt | ||
| contents: Boy | ||
| - type: commit | ||
| message: Add morty | ||
| id: morty-initial-commit | ||
| - type: branch | ||
| branch-name: daughter | ||
| from-commit: morty-initial-commit | ||
| - type: checkout | ||
| branch-name: daughter | ||
| - type: new-file | ||
| filename: beth.txt | ||
| contents: Vet | ||
| - type: commit | ||
| message: Add Beth | ||
| - type: checkout | ||
| branch-name: main | ||
| - type: branch | ||
| branch-name: son-in-law | ||
| from-commit: morty-initial-commit | ||
| - type: checkout | ||
| branch-name: son-in-law | ||
| - type: new-file | ||
| filename: jerry.txt | ||
| contents: Salesman | ||
| - type: commit | ||
| message: Add Jerry | ||
| - type: checkout | ||
| branch-name: main | ||
| - type: edit-file | ||
| filename: morty.txt | ||
| contents: | | ||
| Boy | ||
| Grandson | ||
| - type: commit | ||
| message: Mention Morty is grandson | ||
| - type: merge | ||
| branch-name: daughter | ||
| message: Introduce Beth | ||
| no-ff: true | ||
| - type: merge | ||
| branch-name: son-in-law | ||
| message: introduce Jerry | ||
| no-ff: true |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is necessary