Skip to content

Commit 04f067a

Browse files
committed
deploy: 42eaabe
1 parent 5827725 commit 04f067a

File tree

13 files changed

+202
-0
lines changed

13 files changed

+202
-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-rename",
3+
"tags": [
4+
"git-branch"
5+
],
6+
"requires_git": true,
7+
"requires_github": false,
8+
"base_files": {},
9+
"exercise_repo": {
10+
"repo_type": "local",
11+
"repo_name": "rename-this",
12+
"repo_title": null,
13+
"create_fork": null,
14+
"init": true
15+
}
16+
}

branch_rename/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# branch-rename
2+
3+
You have been working on the login feature for your application on the branch `login`. However, to keep things consistent across other branches, you need to rename it to `feature/login`.
4+
5+
## Task
6+
7+
Rename the `login` branch to `feature/login`.

branch_rename/__init__.py

Whitespace-only changes.

branch_rename/download.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import subprocess
2+
from sys import exit
3+
from typing import List, Optional
4+
5+
6+
def run_command(command: List[str], verbose: bool) -> Optional[str]:
7+
try:
8+
result = subprocess.run(
9+
command,
10+
capture_output=True,
11+
text=True,
12+
check=True,
13+
)
14+
if verbose:
15+
print(result.stdout)
16+
return result.stdout
17+
except subprocess.CalledProcessError as e:
18+
if verbose:
19+
print(e.stderr)
20+
exit(1)
21+
22+
23+
def setup(verbose: bool = False):
24+
run_command(["git", "checkout", "-b", "login"], verbose)
25+
run_command(
26+
["git", "commit", "--allow-empty", "-m", "Implement login feature"], verbose
27+
)
28+
29+
run_command(["git", "checkout", "main"], verbose)

branch_rename/tests/__init__.py

Whitespace-only changes.

branch_rename/tests/specs/base.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
initialization:
2+
steps:
3+
- type: commit
4+
empty: true
5+
message: Empty commit
6+
id: start
7+
- type: branch
8+
branch-name: login
9+
- type: checkout
10+
branch-name: main
11+
- type: branch-rename
12+
branch-name: login
13+
new-name: feature/login
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
initialization:
2+
steps:
3+
- type: commit
4+
empty: true
5+
message: Empty commit
6+
id: start
7+
- type: branch
8+
branch-name: login
9+
- type: checkout
10+
branch-name: main
11+
- type: branch
12+
branch-name: feature/login
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
initialization:
2+
steps:
3+
- type: commit
4+
empty: true
5+
message: Empty commit
6+
id: start
7+
- type: branch
8+
branch-name: login
9+
- type: checkout
10+
branch-name: main
11+
- type: branch-rename
12+
branch-name: login
13+
new-name: not-this
14+
- type: branch
15+
branch-name: feature/login
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
initialization:
2+
steps:
3+
- type: commit
4+
empty: true
5+
message: Empty commit
6+
id: start
7+
- type: branch
8+
branch-name: login
9+
- type: checkout
10+
branch-name: main
11+
- type: branch-rename
12+
branch-name: login
13+
new-name: feature/logi

branch_rename/tests/test_verify.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
from git_autograder import GitAutograderTestLoader, assert_output
2+
from git_autograder.status import GitAutograderStatus
3+
4+
from ..verify import (
5+
FEATURE_LOGIN_MISSING,
6+
LOGIN_STILL_EXISTS,
7+
NO_RENAME_EVIDENCE_FEATURE_LOGIN,
8+
verify,
9+
)
10+
11+
REPOSITORY_NAME = "branch-rename"
12+
13+
loader = GitAutograderTestLoader(__file__, REPOSITORY_NAME, verify)
14+
15+
16+
def test_base():
17+
with loader.load("specs/base.yml") as output:
18+
assert_output(output, GitAutograderStatus.SUCCESSFUL)
19+
20+
21+
def test_new_feature_login_branch():
22+
with loader.load("specs/new_feature_login_branch.yml") as output:
23+
assert_output(output, GitAutograderStatus.UNSUCCESSFUL, [LOGIN_STILL_EXISTS])
24+
25+
26+
def test_rename_login_wrong():
27+
with loader.load("specs/rename_login_wrong.yml") as output:
28+
assert_output(output, GitAutograderStatus.UNSUCCESSFUL, [FEATURE_LOGIN_MISSING])
29+
30+
31+
def test_not_rename():
32+
with loader.load("specs/not_rename.yml") as output:
33+
assert_output(
34+
output, GitAutograderStatus.UNSUCCESSFUL, [NO_RENAME_EVIDENCE_FEATURE_LOGIN]
35+
)

0 commit comments

Comments
 (0)