Skip to content

Commit 65be128

Browse files
committed
[branch-bender] Add branch bender
1 parent dad6943 commit 65be128

File tree

8 files changed

+102
-0
lines changed

8 files changed

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

branch_bender/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# branch-bender
2+
3+
You are building the latest webapp with the coolest features like login, payments, and dashboard.
4+
5+
## Task
6+
7+
You have been working on all of these changes on separate branches and you now want to merge them all into `main`.
8+
9+
### Task 1
10+
11+
Merge the `feature/login` branch into `main` first.
12+
13+
### Task 2
14+
15+
Merge the `feature/dashboard` branch into `main` next.
16+
17+
### Task 3
18+
19+
Merge the `feature/payment` branch into `main` last.
20+
21+
## Final state
22+
23+
The final Git graph (using `git log --oneline --graph`) should look like this:
24+
25+
[![](https://mermaid.ink/img/pako:eNqVkT1vgzAQhv8KuhlRYhMIXlupU6dulZcLPj4UbCPHlkoR_71OmrYRUzvZuve9574WaKwiENAN_tnh1EvTWK0HL83RoWn6pCX0wdHDaLvB_Ko_b0_NyQafaLzImlxH25wNSeG5P1p0aktL_oi9A2zQE86ajP9nm7csSCHGo0HFfSzSJIkE35MmCSJ-FbUYRi9BmjVaMXj7OpsGhHeBUgiTQk9PA3YONYgWx3OMTmjerNXfJmdD19-LIBZ4B1GUeZYXVcmrmtfFnu9SmEGwkmUVyyvOy4Ltq8NuTeHjSsuzkkUbY6wuduxQl3UKnbs0fqtDRpF7tCFOJXgdcaQGb93L17GvN18_AQn5sis?type=png)](https://mermaid.live/edit#pako:eNqVkT1vgzAQhv8KuhlRYhMIXlupU6dulZcLPj4UbCPHlkoR_71OmrYRUzvZuve9574WaKwiENAN_tnh1EvTWK0HL83RoWn6pCX0wdHDaLvB_Ko_b0_NyQafaLzImlxH25wNSeG5P1p0aktL_oi9A2zQE86ajP9nm7csSCHGo0HFfSzSJIkE35MmCSJ-FbUYRi9BmjVaMXj7OpsGhHeBUgiTQk9PA3YONYgWx3OMTmjerNXfJmdD19-LIBZ4B1GUeZYXVcmrmtfFnu9SmEGwkmUVyyvOy4Ltq8NuTeHjSsuzkkUbY6wuduxQl3UKnbs0fqtDRpF7tCFOJXgdcaQGb93L17GvN18_AQn5sis)

branch_bender/__init__.py

Whitespace-only changes.

branch_bender/download.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import subprocess
2+
from sys import exit
3+
from typing import List, Optional
4+
5+
__resources__ = {}
6+
7+
8+
def run_command(command: List[str], verbose: bool) -> Optional[str]:
9+
try:
10+
result = subprocess.run(
11+
command,
12+
capture_output=True,
13+
text=True,
14+
check=True,
15+
)
16+
if verbose:
17+
print(result.stdout)
18+
return result.stdout
19+
except subprocess.CalledProcessError as e:
20+
if verbose:
21+
print(e.stderr)
22+
exit(1)
23+
24+
25+
def setup(verbose: bool = False):
26+
commits_str = run_command(
27+
["git", "log", "--reverse", "--pretty=format:%h"], verbose
28+
)
29+
assert commits_str is not None
30+
first_commit = commits_str.split("\n")[0]
31+
tag_name = f"git-mastery-start-{first_commit}"
32+
run_command(["git", "tag", tag_name], verbose)

branch_bender/tests/__init__.py

Whitespace-only changes.

branch_bender/tests/specs/base.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
initialization:
2+
steps:
3+
- type: commit
4+
empty: true
5+
message: Empty commit
6+
id: start

branch_bender/tests/test_verify.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from git_autograder import GitAutograderTestLoader
2+
3+
from ..verify import verify
4+
5+
REPOSITORY_NAME = "branch-bender"
6+
7+
loader = GitAutograderTestLoader(__file__, REPOSITORY_NAME, verify)
8+
9+
10+
def test():
11+
with loader.load("specs/base.yml", "start"):
12+
pass

branch_bender/verify.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from git_autograder import (
2+
GitAutograderOutput,
3+
GitAutograderExercise,
4+
GitAutograderStatus,
5+
)
6+
7+
8+
def verify(exercise: GitAutograderExercise) -> GitAutograderOutput:
9+
# INSERT YOUR GRADING CODE HERE
10+
11+
return exercise.to_output([], GitAutograderStatus.SUCCESSFUL)

0 commit comments

Comments
 (0)