-
Notifications
You must be signed in to change notification settings - Fork 26
Implement exercise T6L1/branch-previous #125
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
jiaxinnns
wants to merge
18
commits into
git-mastery:main
Choose a base branch
from
jiaxinnns:feature/branch-previous
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
18 commits
Select commit
Hold shift + click to select a range
5d875a1
Add setup instructions
bf4791d
Add autograder logic
3e0ed4a
Add first draft of test cases
d12f986
Edit autograding logic
fa14668
Remove checkout main at the end of tests
jiaxinnns cb18aa3
Fix write to file functionality in tests
jiaxinnns 8ffb739
Change expected error for missing commit
jiaxinnns aa28ab8
Add test for branch from third commit
jiaxinnns 58ffe26
Clean up code
jiaxinnns c0c2e3f
Change branching logic in tests
jiaxinnns 80e5020
Fix issues with HEAD logic
jiaxinnns a7ae7b8
Replace echo steps with repo-smith equivalent
94c2016
Use mermaid to render git graph
9483824
Edit commit searching and matching logic
bfbe0ce
Remove resource block
05af3f5
Remove Commit import
02e4f05
Use hexsha to compare commits
af63ff1
Refactor get_commit_from_message
jiaxinnns 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,16 @@ | ||
| { | ||
| "exercise_name": "branch-previous", | ||
| "tags": [ | ||
| "git-branch" | ||
| ], | ||
| "requires_git": true, | ||
| "requires_github": false, | ||
| "base_files": {}, | ||
| "exercise_repo": { | ||
| "repo_type": "local", | ||
| "repo_name": "horror-story", | ||
| "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,33 @@ | ||
| # branch-previous | ||
|
|
||
| You are writing the outline for a story, in `story.txt`. | ||
|
|
||
| You have written the first few steps of the storyline. | ||
|
|
||
| You are not very happy with the way the story is progressing, and wish to explore a few alternative storylines starting from a previous step. | ||
|
|
||
| ## Task | ||
|
|
||
| 1. Start a new branch named `visitor-line`, starting from the second commit (i.e., commit `Add second line`). | ||
| 2. Add the line `I heard someone knocking at the door`. to the `story.txt`. | ||
| 3. Commit the change. You may use any suitable commit message. | ||
| 4. Start a new branch named `sleep-line`, starting from the same starting point as before. | ||
| 5. Add the line `I fell asleep on the couch`. to the `story.txt`. | ||
| 6. Commit the change. You may use any suitable commit message. | ||
|
|
||
| ## Expected Revision Graph | ||
|
|
||
| ```mermaid | ||
| gitGraph BT: | ||
| commit id: "Describe night" | ||
| commit id: "Describe location" | ||
| branch visitor-line | ||
| checkout main | ||
| branch sleep-line | ||
| checkout main | ||
| commit id: "Mention noise" | ||
| checkout visitor-line | ||
| commit id: "Mention knocking" | ||
| checkout sleep-line | ||
| commit id: "Mention sleeping" | ||
| ``` |
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,30 @@ | ||
| from exercise_utils.file import create_or_update_file, append_to_file | ||
| from exercise_utils.git import add, commit | ||
|
|
||
| def setup(verbose: bool = False): | ||
| create_or_update_file( | ||
| "story.txt", | ||
| """ | ||
| It was a dark and stormy night. | ||
| """ | ||
| ) | ||
| add(["story.txt"], verbose) | ||
| commit("Describe night", verbose) | ||
|
|
||
| append_to_file( | ||
| "story.txt", | ||
| """ | ||
| I was alone in my room. | ||
| """ | ||
| ) | ||
| add(["story.txt"], verbose) | ||
| commit("Describe location", verbose) | ||
|
|
||
| append_to_file( | ||
| "story.txt", | ||
| """ | ||
| I heard a strange noise. | ||
| """ | ||
| ) | ||
| add(["story.txt"], verbose) | ||
| commit("Mention noise", verbose) |
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,52 @@ | ||
| initialization: | ||
| steps: | ||
| - type: new-file | ||
| filename: story.txt | ||
| contents: "It was a dark and stormy night.\n" | ||
| - type: add | ||
| files: | ||
| - story.txt | ||
| - type: commit | ||
| message: Describe night | ||
| id: start | ||
| - type: append-file | ||
| filename: story.txt | ||
| contents: "I was alone in my room.\n" | ||
| - type: add | ||
| files: | ||
| - story.txt | ||
| - type: commit | ||
| message: Describe location | ||
| empty: false | ||
| id: describe_location_commit | ||
| - type: append-file | ||
| filename: story.txt | ||
| contents: "I heard a strange noise.\n" | ||
| - type: add | ||
| files: | ||
| - story.txt | ||
| - type: commit | ||
| message: Mention noise | ||
| empty: false | ||
| - type: bash | ||
| runs: git checkout -b visitor-line HEAD~1 | ||
| - type: append-file | ||
| filename: story.txt | ||
| contents: "I heard someone knocking at the door.\n" | ||
| - type: add | ||
| files: | ||
| - story.txt | ||
| - type: commit | ||
| message: Mention knocking | ||
| empty: false | ||
| - type: bash | ||
| runs: git checkout -b sleep-line HEAD~1 | ||
| - type: append-file | ||
| filename: story.txt | ||
| contents: "I fell asleep on the couch.\n" | ||
| - type: add | ||
| files: | ||
| - story.txt | ||
| - type: commit | ||
| message: Mention sleeping | ||
| empty: false | ||
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,43 @@ | ||
| initialization: | ||
| steps: | ||
| - type: new-file | ||
| filename: story.txt | ||
| contents: "It was a dark and stormy night.\n" | ||
| - type: add | ||
| files: | ||
| - story.txt | ||
| - type: commit | ||
| message: Describe night | ||
| empty: false | ||
| id: start | ||
| - type: append-file | ||
| filename: story.txt | ||
| contents: "I was alone in my room.\n" | ||
| - type: add | ||
| files: | ||
| - story.txt | ||
| - type: commit | ||
| message: Describe location | ||
| empty: false | ||
| id: describe_location_commit | ||
| - type: append-file | ||
| filename: story.txt | ||
| contents: "I heard a strange noise.\n" | ||
| - type: add | ||
| files: | ||
| - story.txt | ||
| - type: commit | ||
| message: Mention noise | ||
| empty: false | ||
| # Only create visitor-line branch, not sleep-line | ||
| - type: bash | ||
| runs: git checkout -b visitor-line HEAD~1 | ||
| - type: append-file | ||
| filename: story.txt | ||
| contents: "I heard someone knocking at the door.\n" | ||
| - type: add | ||
| files: | ||
| - story.txt | ||
| - type: commit | ||
| message: Mention knocking | ||
| empty: false |
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,53 @@ | ||
| initialization: | ||
| steps: | ||
| - type: new-file | ||
| filename: story.txt | ||
| contents: "It was a dark and stormy night.\n" | ||
| - type: add | ||
| files: | ||
| - story.txt | ||
| - type: commit | ||
| message: Describe night | ||
| empty: false | ||
| id: start | ||
| - type: append-file | ||
| filename: story.txt | ||
| contents: "I was alone in my room.\n" | ||
| - type: add | ||
| files: | ||
| - story.txt | ||
| - type: commit | ||
| message: Describe location | ||
| empty: false | ||
| id: describe_location_commit | ||
| - type: append-file | ||
| filename: story.txt | ||
| contents: "I heard a strange noise.\n" | ||
| - type: add | ||
| files: | ||
| - story.txt | ||
| - type: commit | ||
| message: Mention noise | ||
| empty: false | ||
| - type: bash | ||
| runs: git checkout -b visitor-line HEAD~1 | ||
| - type: append-file | ||
| filename: story.txt | ||
| contents: "I heard someone knocking at the door.\n" | ||
| - type: add | ||
| files: | ||
| - story.txt | ||
| - type: commit | ||
| message: Mention knocking | ||
| empty: false | ||
| - type: bash | ||
| runs: git checkout -b sleep-line HEAD~1 | ||
| - type: append-file | ||
| filename: story.txt | ||
| contents: "Wrong content here.\n" | ||
| - type: add | ||
| files: | ||
| - story.txt | ||
| - type: commit | ||
| message: Mention sleeping | ||
| empty: false |
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: new-file | ||
| filename: story.txt | ||
| contents: "It was a dark and stormy night.\n" | ||
| - type: add | ||
| files: | ||
| - story.txt | ||
| - type: commit | ||
| message: Describe night | ||
| id: start | ||
| - type: append-file | ||
| filename: story.txt | ||
| contents: "I was alone in my room.\n" | ||
| - type: add | ||
| files: | ||
| - story.txt | ||
| - type: commit | ||
| message: Describe location | ||
| empty: false | ||
| id: second_commit | ||
| - type: append-file | ||
| filename: story.txt | ||
| contents: "I heard a strange noise.\n" | ||
| - type: add | ||
| files: | ||
| - story.txt | ||
| - type: commit | ||
| message: Mention noise | ||
| empty: false | ||
| # Only create sleep-line branch, not visitor-line | ||
| - type: bash | ||
| runs: git checkout -b sleep-line HEAD~1 | ||
| - type: append-file | ||
| filename: story.txt | ||
| contents: "I fell asleep on the couch.\n" | ||
| - type: add | ||
| files: | ||
| - story.txt | ||
| - type: commit | ||
| message: Mention sleeping | ||
| empty: false |
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,46 @@ | ||
| initialization: | ||
| steps: | ||
| - type: new-file | ||
| filename: story.txt | ||
| contents: "It was a dark and stormy night.\n" | ||
| - type: add | ||
| files: | ||
| - story.txt | ||
| - type: commit | ||
| message: Describe night | ||
| empty: false | ||
| id: start | ||
| - type: append-file | ||
| filename: story.txt | ||
| contents: "I was alone in my room.\n" | ||
| - type: add | ||
| files: | ||
| - story.txt | ||
| - type: commit | ||
| message: Describe location | ||
| empty: false | ||
| id: describe_location_commit | ||
| - type: append-file | ||
| filename: story.txt | ||
| contents: "I heard a strange noise.\n" | ||
| - type: add | ||
| files: | ||
| - story.txt | ||
| - type: commit | ||
| message: Mention noise | ||
| empty: false | ||
| # visitor-line branch created but no commit made | ||
| - type: bash | ||
| runs: git checkout -b visitor-line HEAD~1 | ||
| # sleep-line branch created with commit | ||
| - type: bash | ||
| runs: git checkout -b sleep-line | ||
| - type: append-file | ||
| filename: story.txt | ||
| contents: "I fell asleep on the couch.\n" | ||
| - type: add | ||
| files: | ||
| - story.txt | ||
| - type: commit | ||
| message: Mention sleeping | ||
| empty: false |
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,53 @@ | ||
| initialization: | ||
| steps: | ||
| - type: new-file | ||
| filename: story.txt | ||
| contents: "It was a dark and stormy night.\n" | ||
| - type: add | ||
| files: | ||
| - story.txt | ||
| - type: commit | ||
| message: Describe night | ||
| empty: false | ||
| id: start | ||
| - type: append-file | ||
| filename: story.txt | ||
| contents: "I was alone in my room.\n" | ||
| - type: add | ||
| files: | ||
| - story.txt | ||
| - type: commit | ||
| message: Describe location | ||
| empty: false | ||
| id: describe_location_commit | ||
| - type: append-file | ||
| filename: story.txt | ||
| contents: "I heard a strange noise.\n" | ||
| - type: add | ||
| files: | ||
| - story.txt | ||
| - type: commit | ||
| message: Mention noise | ||
| empty: false | ||
| - type: bash | ||
| runs: git checkout -b visitor-line HEAD~1 | ||
| - type: append-file | ||
| filename: story.txt | ||
| contents: "Wrong content here.\n" | ||
| - type: add | ||
| files: | ||
| - story.txt | ||
| - type: commit | ||
| message: Mention knocking | ||
| empty: false | ||
| - type: bash | ||
| runs: git checkout -b sleep-line HEAD~1 | ||
| - type: append-file | ||
| filename: story.txt | ||
| contents: "I fell asleep on my couch.\n" | ||
| - type: add | ||
| files: | ||
| - story.txt | ||
| - type: commit | ||
| message: Mention sleeping | ||
| empty: false |
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 have also implemented the support for
start-pointinrepo-smith, so we can wait for it to get merged.git-mastery/repo-smith#4