From 32979c8453acee01f6adb8a2b36c5ab1c6ae2762 Mon Sep 17 00:00:00 2001 From: jovnc <95868357+jovnc@users.noreply.github.com> Date: Sat, 7 Feb 2026 11:04:31 +0800 Subject: [PATCH 1/4] [remote-branch-rename] Improve exercise and update test --- remote_branch_rename/download.py | 5 -- remote_branch_rename/test_verify.py | 78 +++++------------------------ remote_branch_rename/verify.py | 20 +------- 3 files changed, 13 insertions(+), 90 deletions(-) diff --git a/remote_branch_rename/download.py b/remote_branch_rename/download.py index 0d572cc8..7ed5d6c3 100644 --- a/remote_branch_rename/download.py +++ b/remote_branch_rename/download.py @@ -2,11 +2,6 @@ def setup(verbose: bool = False): - checkout("try-quick-fix", True, verbose) - empty_commit("Fixed scrolling issue", verbose) - - checkout("main", False, verbose) - checkout("improve-loadding", True, verbose) empty_commit("Improved loading of page", verbose) diff --git a/remote_branch_rename/test_verify.py b/remote_branch_rename/test_verify.py index e5341910..b063d297 100644 --- a/remote_branch_rename/test_verify.py +++ b/remote_branch_rename/test_verify.py @@ -1,6 +1,5 @@ from contextlib import contextmanager from typing import Iterator, Tuple -from unittest.mock import patch from repo_smith.repo_smith import RepoSmith @@ -13,13 +12,10 @@ from git_autograder import GitAutograderStatus from .verify import ( - FIX_SCROLLING_BUG_MISSING, IMPROVE_LOADING_LOCAL_MISSING, IMPROVE_LOADING_LOCAL_STILL_EXISTS, IMPROVE_LOADING_REMOTE_MISSING, IMPROVE_LOADING_REMOTE_OLD_PRESENT, - NO_RENAME_EVIDENCE_TRY_QUICK_FIX, - TRY_QUICK_FIX_STILL_EXISTS, verify, ) @@ -30,67 +26,30 @@ @contextmanager def base_setup() -> Iterator[Tuple[GitAutograderTest, RepoSmith]]: - with loader.start() as (test, rs): + with loader.start(include_remote_repo=True) as (test, rs, rs_remote): + remote_worktree_dir = rs_remote.repo.working_tree_dir + rs.git.commit(message="Empty", allow_empty=True) rs.helper(GitMasteryHelper).create_start_tag() - rs.git.branch("try-quick-fix") + rs.git.remote_add("origin", str(remote_worktree_dir)) rs.git.branch("improve-loadding") + rs.git.push("origin", "improve-loadding") yield test, rs def test_base(): - with ( - patch("remote_branch_rename.verify.fetch_remotes", side_effect=None), - patch( - "remote_branch_rename.verify.get_remotes", return_value=["improve-loading"] - ), - base_setup() as (test, rs), - ): - rs.git.branch("fix-scrolling-bug", old_branch="try-quick-fix", move=True) - rs.git.branch("improve-loading", old_branch="improve-loadding", move=True) - - output = test.run() - assert_output(output, GitAutograderStatus.SUCCESSFUL) - - -def test_new_fix_scrolling_bug_branch(): - with base_setup() as (test, rs): - rs.git.branch("fix-scrolling-bug") - rs.git.branch("improve-loading", old_branch="improve-loadding", move=True) - - output = test.run() - assert_output( - output, GitAutograderStatus.UNSUCCESSFUL, [TRY_QUICK_FIX_STILL_EXISTS] - ) - - -def test_rename_quick_fix_wrong(): - with base_setup() as (test, rs): - rs.git.branch("fix-scroling-bug", old_branch="try-quick-fix", move=True) - rs.git.branch("improve-loading", old_branch="improve-loadding", move=True) - - output = test.run() - assert_output( - output, GitAutograderStatus.UNSUCCESSFUL, [FIX_SCROLLING_BUG_MISSING] - ) - - -def test_not_quick_fix_rename(): with base_setup() as (test, rs): - rs.git.branch("not-this", old_branch="try-quick-fix", move=True) rs.git.branch("improve-loading", old_branch="improve-loadding", move=True) - rs.git.branch("fix-scrolling-bug") + rs.git.push("origin", "improve-loading") + rs.git.push("origin", ":improve-loadding") output = test.run() - assert_output( - output, GitAutograderStatus.UNSUCCESSFUL, [NO_RENAME_EVIDENCE_TRY_QUICK_FIX] - ) + assert_output(output, GitAutograderStatus.SUCCESSFUL) def test_new_improve_loading_branch(): with base_setup() as (test, rs): - rs.git.branch("fix-scrolling-bug", old_branch="try-quick-fix", move=True) rs.git.branch("improve-loading") output = test.run() @@ -103,7 +62,6 @@ def test_new_improve_loading_branch(): def test_rename_improve_loading_wrong(): with base_setup() as (test, rs): - rs.git.branch("fix-scrolling-bug", old_branch="try-quick-fix", move=True) rs.git.branch("improve-loaing", old_branch="improve-loadding", move=True) output = test.run() @@ -115,15 +73,9 @@ def test_rename_improve_loading_wrong(): def test_improve_loadding_remote_exists(): - with ( - patch("remote_branch_rename.verify.fetch_remotes", side_effect=None), - patch( - "remote_branch_rename.verify.get_remotes", return_value=["improve-loadding"] - ), - base_setup() as (test, rs), - ): - rs.git.branch("fix-scrolling-bug", old_branch="try-quick-fix", move=True) + with base_setup() as (test, rs): rs.git.branch("improve-loading", old_branch="improve-loadding", move=True) + rs.git.push("origin", "improve-loading") output = test.run() assert_output( @@ -134,15 +86,9 @@ def test_improve_loadding_remote_exists(): def test_improve_loading_remote_missing(): - with ( - patch("remote_branch_rename.verify.fetch_remotes", side_effect=None), - patch( - "remote_branch_rename.verify.get_remotes", return_value=["improve-loaing"] - ), - base_setup() as (test, rs), - ): - rs.git.branch("fix-scrolling-bug", old_branch="try-quick-fix", move=True) + with base_setup() as (test, rs): rs.git.branch("improve-loading", old_branch="improve-loadding", move=True) + rs.git.push("origin", ":improve-loadding") output = test.run() assert_output( diff --git a/remote_branch_rename/verify.py b/remote_branch_rename/verify.py index e4d69736..6f56eecf 100644 --- a/remote_branch_rename/verify.py +++ b/remote_branch_rename/verify.py @@ -8,14 +8,6 @@ GitAutograderStatus, ) -TRY_QUICK_FIX_STILL_EXISTS = ( - "Branch 'try-quick-fix' still exists! Remember to rename it to 'fix-scrolling-bug'" -) -FIX_SCROLLING_BUG_MISSING = "Branch 'fix-scrolling-bug' is missing, did you correctly rename the branch 'try-quick-fix' to 'fix-scrolling-bug'?" -NO_RENAME_EVIDENCE_TRY_QUICK_FIX = ( - "Branch 'try-quick-fix' was not renamed to 'fix-scrolling-bug'!" -) - IMPROVE_LOADING_LOCAL_STILL_EXISTS = "Local branch 'improve-loadding' still exists! Remember to rename it to 'improve-loading'" IMPROVE_LOADING_LOCAL_MISSING = "Local branch 'improve-loading' is missing, did you correctly rename the branch 'improve-loadding' to 'improve-loading'?" NO_RENAME_EVIDENCE_IMPROVE_LOADING = ( @@ -72,18 +64,8 @@ def has_remote(remotes: List[str], target: str) -> bool: def verify(exercise: GitAutograderExercise) -> GitAutograderOutput: repo: Repo = exercise.repo.repo - # try-quick-fix -> fix-scrolling-bug - local_branches = [h.name for h in repo.heads] - if "try-quick-fix" in local_branches: - raise exercise.wrong_answer([TRY_QUICK_FIX_STILL_EXISTS]) - - if "fix-scrolling-bug" not in local_branches: - raise exercise.wrong_answer([FIX_SCROLLING_BUG_MISSING]) - - if not branch_has_rename_evidence(exercise, "fix-scrolling-bug", "try-quick-fix"): - raise exercise.wrong_answer([NO_RENAME_EVIDENCE_TRY_QUICK_FIX]) - # improve-loadding -> improve-loading + local_branches = [h.name for h in repo.heads] if "improve-loadding" in local_branches: raise exercise.wrong_answer([IMPROVE_LOADING_LOCAL_STILL_EXISTS]) From 76531699b21868d4d94bac8326b45620c0c6d0f1 Mon Sep 17 00:00:00 2001 From: jovnc <95868357+jovnc@users.noreply.github.com> Date: Sat, 7 Feb 2026 11:16:09 +0800 Subject: [PATCH 2/4] [remote-branch-rename] Update tests --- remote_branch_rename/test_verify.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/remote_branch_rename/test_verify.py b/remote_branch_rename/test_verify.py index b063d297..63d60a0a 100644 --- a/remote_branch_rename/test_verify.py +++ b/remote_branch_rename/test_verify.py @@ -6,7 +6,6 @@ from exercise_utils.test import ( GitAutograderTest, GitAutograderTestLoader, - GitMasteryHelper, assert_output, ) from git_autograder import GitAutograderStatus @@ -27,11 +26,10 @@ @contextmanager def base_setup() -> Iterator[Tuple[GitAutograderTest, RepoSmith]]: with loader.start(include_remote_repo=True) as (test, rs, rs_remote): - remote_worktree_dir = rs_remote.repo.working_tree_dir + remote_path = str(rs_remote.repo.git_dir) - rs.git.commit(message="Empty", allow_empty=True) - rs.helper(GitMasteryHelper).create_start_tag() - rs.git.remote_add("origin", str(remote_worktree_dir)) + rs.git.commit(message="Improved loading of page", allow_empty=True) + rs.git.remote_add("origin", remote_path) rs.git.branch("improve-loadding") rs.git.push("origin", "improve-loadding") From 339b0dd1dd29af38bff313f307048b37b809df75 Mon Sep 17 00:00:00 2001 From: jovnc <95868357+jovnc@users.noreply.github.com> Date: Sat, 7 Feb 2026 11:17:48 +0800 Subject: [PATCH 3/4] [remote-branch-rename] Add tests --- remote_branch_rename/test_verify.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/remote_branch_rename/test_verify.py b/remote_branch_rename/test_verify.py index 63d60a0a..4a2f1c6c 100644 --- a/remote_branch_rename/test_verify.py +++ b/remote_branch_rename/test_verify.py @@ -15,6 +15,7 @@ IMPROVE_LOADING_LOCAL_STILL_EXISTS, IMPROVE_LOADING_REMOTE_MISSING, IMPROVE_LOADING_REMOTE_OLD_PRESENT, + NO_RENAME_EVIDENCE_IMPROVE_LOADING, verify, ) @@ -70,6 +71,19 @@ def test_rename_improve_loading_wrong(): ) +def test_improve_loading_no_rename_evidence(): + with base_setup() as (test, rs): + rs.git.branch("improve-loading") + rs.git.branch("improve-loadding", delete=True) + + output = test.run() + assert_output( + output, + GitAutograderStatus.UNSUCCESSFUL, + [NO_RENAME_EVIDENCE_IMPROVE_LOADING], + ) + + def test_improve_loadding_remote_exists(): with base_setup() as (test, rs): rs.git.branch("improve-loading", old_branch="improve-loadding", move=True) From 94a05803d5dc72d9b489f72eb7ccbf24e7a705d8 Mon Sep 17 00:00:00 2001 From: jovnc <95868357+jovnc@users.noreply.github.com> Date: Sat, 7 Feb 2026 11:22:05 +0800 Subject: [PATCH 4/4] [remote-branch-rename] Fix typo in existing message --- remote_branch_rename/verify.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remote_branch_rename/verify.py b/remote_branch_rename/verify.py index 6f56eecf..3bc653aa 100644 --- a/remote_branch_rename/verify.py +++ b/remote_branch_rename/verify.py @@ -14,7 +14,7 @@ "Local branch 'improve-loadding' was not renamed to 'improve-loading'!" ) IMPROVE_LOADING_REMOTE_MISSING = "Remote branch 'improve-loading' is missing, did you correctly push the renamed branch to the remote?" -IMPROVE_LOADING_REMOTE_OLD_PRESENT = "Remote branch 'improve-loadding' still exists! Remember to rename it to 'improve-loadding'" +IMPROVE_LOADING_REMOTE_OLD_PRESENT = "Remote branch 'improve-loadding' still exists! Remember to rename it to 'improve-loading'" def branch_has_rename_evidence(