From ff275e1f4593c66dc69205b10e77a779ae4e70f6 Mon Sep 17 00:00:00 2001 From: lavanyagarg112 Date: Wed, 5 Nov 2025 18:15:10 +0800 Subject: [PATCH 01/14] initialise exercise --- branch_compare/.gitmastery-exercise.json | 17 +++++++++++++++++ branch_compare/README.md | 18 ++++++++++++++++++ branch_compare/__init__.py | 0 branch_compare/download.py | 8 ++++++++ branch_compare/tests/__init__.py | 0 branch_compare/tests/specs/base.yml | 6 ++++++ branch_compare/tests/test_verify.py | 12 ++++++++++++ branch_compare/verify.py | 11 +++++++++++ 8 files changed, 72 insertions(+) create mode 100644 branch_compare/.gitmastery-exercise.json create mode 100644 branch_compare/README.md create mode 100644 branch_compare/__init__.py create mode 100644 branch_compare/download.py create mode 100644 branch_compare/tests/__init__.py create mode 100644 branch_compare/tests/specs/base.yml create mode 100644 branch_compare/tests/test_verify.py create mode 100644 branch_compare/verify.py diff --git a/branch_compare/.gitmastery-exercise.json b/branch_compare/.gitmastery-exercise.json new file mode 100644 index 0000000..f456c3b --- /dev/null +++ b/branch_compare/.gitmastery-exercise.json @@ -0,0 +1,17 @@ +{ + "exercise_name": "branch-compare", + "tags": [ + "git-branch", + "git-diff" + ], + "requires_git": true, + "requires_github": false, + "base_files": {}, + "exercise_repo": { + "repo_type": "local", + "repo_name": "data_streams", + "repo_title": null, + "create_fork": null, + "init": true + } +} \ No newline at end of file diff --git a/branch_compare/README.md b/branch_compare/README.md new file mode 100644 index 0000000..7c6eb54 --- /dev/null +++ b/branch_compare/README.md @@ -0,0 +1,18 @@ +# branch-compare + + + +## Task + + + +## Hints + + + diff --git a/branch_compare/__init__.py b/branch_compare/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/branch_compare/download.py b/branch_compare/download.py new file mode 100644 index 0000000..df0bbc2 --- /dev/null +++ b/branch_compare/download.py @@ -0,0 +1,8 @@ +from exercise_utils.cli import run_command +from exercise_utils.gitmastery import create_start_tag + +__resources__ = {} + + +def setup(verbose: bool = False): + create_start_tag(verbose) diff --git a/branch_compare/tests/__init__.py b/branch_compare/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/branch_compare/tests/specs/base.yml b/branch_compare/tests/specs/base.yml new file mode 100644 index 0000000..00c3a53 --- /dev/null +++ b/branch_compare/tests/specs/base.yml @@ -0,0 +1,6 @@ +initialization: + steps: + - type: commit + empty: true + message: Empty commit + id: start diff --git a/branch_compare/tests/test_verify.py b/branch_compare/tests/test_verify.py new file mode 100644 index 0000000..420d9b6 --- /dev/null +++ b/branch_compare/tests/test_verify.py @@ -0,0 +1,12 @@ +from git_autograder import GitAutograderTestLoader + +from ..verify import verify + +REPOSITORY_NAME = "branch-compare" + +loader = GitAutograderTestLoader(__file__, REPOSITORY_NAME, verify) + + +def test_base(): + with loader.load("specs/base.yml", "start"): + pass diff --git a/branch_compare/verify.py b/branch_compare/verify.py new file mode 100644 index 0000000..1288d3d --- /dev/null +++ b/branch_compare/verify.py @@ -0,0 +1,11 @@ +from git_autograder import ( + GitAutograderOutput, + GitAutograderExercise, + GitAutograderStatus, +) + + +def verify(exercise: GitAutograderExercise) -> GitAutograderOutput: + # INSERT YOUR GRADING CODE HERE + + return exercise.to_output([], GitAutograderStatus.SUCCESSFUL) From 6fe556698295d156ed9b5a22cc21e0b7eed02179 Mon Sep 17 00:00:00 2001 From: lavanyagarg112 Date: Wed, 5 Nov 2025 18:18:47 +0800 Subject: [PATCH 02/14] setup task instructions and answers.txt --- branch_compare/README.md | 15 +++------------ branch_compare/res/answers.txt | 5 +++++ 2 files changed, 8 insertions(+), 12 deletions(-) create mode 100644 branch_compare/res/answers.txt diff --git a/branch_compare/README.md b/branch_compare/README.md index 7c6eb54..f3ac437 100644 --- a/branch_compare/README.md +++ b/branch_compare/README.md @@ -1,18 +1,9 @@ # branch-compare - - ## Task - +You are recording a numerical data stream from two sources. The data are stored in `data.txt`, using a different branch for each stream. The two data streams are supposed to be identical but can vary on rare occasions. -## Hints +Answer the questions given in `answers.txt`. - - +Run `gitmastery verify` to check if your answers are correct. diff --git a/branch_compare/res/answers.txt b/branch_compare/res/answers.txt new file mode 100644 index 0000000..034c8e2 --- /dev/null +++ b/branch_compare/res/answers.txt @@ -0,0 +1,5 @@ +Q: Which numbers are present in stream-1 but not in stream-2? +A: + +Q: Which numbers are present in stream-2 but not in stream-1? +A: From 0b2d8086f9ffa404228f817232a8a43c771f15c9 Mon Sep 17 00:00:00 2001 From: lavanyagarg112 Date: Wed, 5 Nov 2025 18:52:50 +0800 Subject: [PATCH 03/14] add setup for this exercise --- branch_compare/download.py | 53 +++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/branch_compare/download.py b/branch_compare/download.py index df0bbc2..de6a4af 100644 --- a/branch_compare/download.py +++ b/branch_compare/download.py @@ -1,8 +1,59 @@ from exercise_utils.cli import run_command +from exercise_utils.git import add, commit, checkout +from exercise_utils.file import append_to_file from exercise_utils.gitmastery import create_start_tag +import random + __resources__ = {} +def get_sequence(n=1000, digits=8, seed=None): + rng = random.Random(seed) + lo, hi = 10**(digits - 1), 10**digits - 1 + return rng.sample(range(lo, hi + 1), k=n) + +def get_modified_sequence(seq, digits=8, idx=None, seed=None): + rng = random.Random(seed) + n = len(seq) + if idx is None: + idx = rng.randrange(n) + + modified = seq.copy() + seen = set(seq) + lo, hi = 10**(digits - 1), 10**digits - 1 + + old = modified[idx] + new = old + while new in seen: + new = rng.randint(lo, hi) + modified[idx] = new + return modified + def setup(verbose: bool = False): - create_start_tag(verbose) + + orig_data = get_sequence() + + run_command(["touch", "data.txt"], verbose) + add(["data.txt"], verbose) + commit("Add empty data.txt", verbose) + checkout("stream-1", True, verbose) + + for i in orig_data: + append_to_file("data.txt", str(i)+"\n") + + add(["data.txt"], verbose) + commit("Add data to data.txt", verbose) + + + checkout("main", False, verbose) + checkout("stream-2", True, verbose) + + for i in get_modified_sequence(orig_data): + append_to_file("data.txt", str(i)+"\n") + + add(["data.txt"], verbose) + commit("Add data to data.txt", verbose) + + checkout("main", False, verbose) + From ff7c730160b21b8804c220618a0d48f98bf8cadb Mon Sep 17 00:00:00 2001 From: lavanyagarg112 Date: Wed, 5 Nov 2025 18:56:13 +0800 Subject: [PATCH 04/14] update setup --- branch_compare/download.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/branch_compare/download.py b/branch_compare/download.py index de6a4af..f0f5c12 100644 --- a/branch_compare/download.py +++ b/branch_compare/download.py @@ -32,7 +32,10 @@ def get_modified_sequence(seq, digits=8, idx=None, seed=None): def setup(verbose: bool = False): + create_start_tag(verbose) + orig_data = get_sequence() + modified_data = get_modified_sequence(orig_data) run_command(["touch", "data.txt"], verbose) add(["data.txt"], verbose) @@ -49,7 +52,7 @@ def setup(verbose: bool = False): checkout("main", False, verbose) checkout("stream-2", True, verbose) - for i in get_modified_sequence(orig_data): + for i in modified_data: append_to_file("data.txt", str(i)+"\n") add(["data.txt"], verbose) From 73c727d28f219cfafea5a9b36d98396cd6902381 Mon Sep 17 00:00:00 2001 From: lavanyagarg112 Date: Sat, 8 Nov 2025 00:27:34 +0800 Subject: [PATCH 05/14] update exercise json --- branch_compare/.gitmastery-exercise.json | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/branch_compare/.gitmastery-exercise.json b/branch_compare/.gitmastery-exercise.json index f456c3b..934bbf7 100644 --- a/branch_compare/.gitmastery-exercise.json +++ b/branch_compare/.gitmastery-exercise.json @@ -1,12 +1,11 @@ { "exercise_name": "branch-compare", - "tags": [ - "git-branch", - "git-diff" - ], + "tags": ["git-branch", "git-diff"], "requires_git": true, "requires_github": false, - "base_files": {}, + "base_files": { + "answers.txt": "answers.txt" + }, "exercise_repo": { "repo_type": "local", "repo_name": "data_streams", @@ -14,4 +13,4 @@ "create_fork": null, "init": true } -} \ No newline at end of file +} From 00cb16ca06a1c37e05481488f4005aa337b3dd31 Mon Sep 17 00:00:00 2001 From: lavanyagarg112 Date: Sat, 8 Nov 2025 01:14:36 +0800 Subject: [PATCH 06/14] add basic verify function --- branch_compare/verify.py | 47 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/branch_compare/verify.py b/branch_compare/verify.py index 1288d3d..7861318 100644 --- a/branch_compare/verify.py +++ b/branch_compare/verify.py @@ -4,8 +4,51 @@ GitAutograderStatus, ) +from git_autograder.answers.rules import HasExactValueRule, NotEmptyRule + + +QUESTION_ONE = "Which numbers are present in stream-1 but not in stream-2?" +QUESTION_TWO = "Which numbers are present in stream-2 but not in stream-1?" + +FILE_PATH = "data.txt" +BRANCH_1 = "stream-1" +BRANCH_2 = "stream-2" + +def get_branch_diff(exercise: GitAutograderExercise, branch1: str, branch2: str) -> str: + exercise.repo.branches.branch(branch1).checkout() + with exercise.repo.files.file(FILE_PATH) as f1: + contents1 = f1.read() + + exercise.repo.branches.branch(branch2).checkout() + with exercise.repo.files.file(FILE_PATH) as f2: + contents2 = f2.read() + + exercise.repo.branches.branch("main").checkout() + + set1 = set(contents1.splitlines()) + set2 = set(contents2.splitlines()) + diff = set1 - set2 + return str(diff.pop()) + +def get_stream1_diff(exercise: GitAutograderExercise) -> str: + return get_branch_diff(exercise, BRANCH_1, BRANCH_2) + +def get_stream2_diff(exercise: GitAutograderExercise) -> str: + return get_branch_diff(exercise, BRANCH_2, BRANCH_1) def verify(exercise: GitAutograderExercise) -> GitAutograderOutput: - # INSERT YOUR GRADING CODE HERE - return exercise.to_output([], GitAutograderStatus.SUCCESSFUL) + ans_1 = get_stream1_diff(exercise) + ans_2 = get_stream2_diff(exercise) + + exercise.answers.add_validation( + QUESTION_ONE, + NotEmptyRule(), + HasExactValueRule(ans_1), + ).add_validation( + QUESTION_TWO, + NotEmptyRule(), + HasExactValueRule(ans_2), + ).validate() + + return exercise.to_output(["Great work comparing the branches successfully!"], GitAutograderStatus.SUCCESSFUL) From 9e662fb9d1307d1d0c7326cd7a14db497be1c955 Mon Sep 17 00:00:00 2001 From: lavanyagarg112 Date: Sat, 8 Nov 2025 19:46:32 +0800 Subject: [PATCH 07/14] add base test --- branch_compare/tests/test_verify.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/branch_compare/tests/test_verify.py b/branch_compare/tests/test_verify.py index 420d9b6..ae541c5 100644 --- a/branch_compare/tests/test_verify.py +++ b/branch_compare/tests/test_verify.py @@ -1,6 +1,7 @@ -from git_autograder import GitAutograderTestLoader +from git_autograder import GitAutograderStatus, GitAutograderTestLoader, assert_output +from unittest.mock import patch -from ..verify import verify +from ..verify import verify, QUESTION_ONE, QUESTION_TWO REPOSITORY_NAME = "branch-compare" @@ -8,5 +9,16 @@ def test_base(): - with loader.load("specs/base.yml", "start"): - pass + with ( + patch("branch_compare.verify.get_stream1_diff", return_value="12345"), + patch("branch_compare.verify.get_stream2_diff", return_value="98765"), + loader.load( + "specs/base.yml", + "start", + mock_answers={ + QUESTION_ONE: "12345", + QUESTION_TWO: "98765", + } + ) as output, + ): + assert_output(output, GitAutograderStatus.SUCCESSFUL) From 9eccc4d84ff64c263bb38326ddaf5b3519322892 Mon Sep 17 00:00:00 2001 From: lavanyagarg112 Date: Sat, 8 Nov 2025 19:50:39 +0800 Subject: [PATCH 08/14] add unittest for invalid cases --- branch_compare/tests/test_verify.py | 39 +++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/branch_compare/tests/test_verify.py b/branch_compare/tests/test_verify.py index ae541c5..421dabf 100644 --- a/branch_compare/tests/test_verify.py +++ b/branch_compare/tests/test_verify.py @@ -1,5 +1,6 @@ from git_autograder import GitAutograderStatus, GitAutograderTestLoader, assert_output from unittest.mock import patch +from git_autograder.answers.rules.has_exact_value_rule import HasExactValueRule from ..verify import verify, QUESTION_ONE, QUESTION_TWO @@ -22,3 +23,41 @@ def test_base(): ) as output, ): assert_output(output, GitAutograderStatus.SUCCESSFUL) + +def test_wrong_stream1_diff(): + with ( + patch("branch_compare.verify.get_stream1_diff", return_value="99999"), + patch("branch_compare.verify.get_stream2_diff", return_value="98765"), + loader.load( + "specs/base.yml", + "start", + mock_answers={ + QUESTION_ONE: "12345", + QUESTION_TWO: "98765", + } + ) as output, + ): + assert_output( + output, + GitAutograderStatus.UNSUCCESSFUL, + [HasExactValueRule.NOT_EXACT.format(question=QUESTION_ONE)], + ) + +def test_wrong_stream2_diff(): + with ( + patch("branch_compare.verify.get_stream1_diff", return_value="12345"), + patch("branch_compare.verify.get_stream2_diff", return_value="99999"), + loader.load( + "specs/base.yml", + "start", + mock_answers={ + QUESTION_ONE: "12345", + QUESTION_TWO: "98765", + } + ) as output, + ): + assert_output( + output, + GitAutograderStatus.UNSUCCESSFUL, + [HasExactValueRule.NOT_EXACT.format(question=QUESTION_TWO)], + ) From 01b9415085c30ceb9867f319e7b7d5b80b73a886 Mon Sep 17 00:00:00 2001 From: lavanyagarg112 Date: Sat, 8 Nov 2025 19:52:00 +0800 Subject: [PATCH 09/14] modify answers.txt --- branch_compare/res/answers.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/branch_compare/res/answers.txt b/branch_compare/res/answers.txt index 034c8e2..37cc88d 100644 --- a/branch_compare/res/answers.txt +++ b/branch_compare/res/answers.txt @@ -1,5 +1,5 @@ Q: Which numbers are present in stream-1 but not in stream-2? -A: +A: Q: Which numbers are present in stream-2 but not in stream-1? A: From 62bf2da39d58e2cdb25d2b0cccbb5378e0dceb68 Mon Sep 17 00:00:00 2001 From: lavanyagarg112 Date: Sat, 8 Nov 2025 20:20:10 +0800 Subject: [PATCH 10/14] modify answers.txt and verify --- branch_compare/res/answers.txt | 4 ++-- branch_compare/verify.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/branch_compare/res/answers.txt b/branch_compare/res/answers.txt index 37cc88d..1f2dbf8 100644 --- a/branch_compare/res/answers.txt +++ b/branch_compare/res/answers.txt @@ -1,5 +1,5 @@ -Q: Which numbers are present in stream-1 but not in stream-2? +Q: Which number is present in stream-1 but not in stream-2? A: -Q: Which numbers are present in stream-2 but not in stream-1? +Q: Which number is present in stream-2 but not in stream-1? A: diff --git a/branch_compare/verify.py b/branch_compare/verify.py index 7861318..690a757 100644 --- a/branch_compare/verify.py +++ b/branch_compare/verify.py @@ -7,8 +7,8 @@ from git_autograder.answers.rules import HasExactValueRule, NotEmptyRule -QUESTION_ONE = "Which numbers are present in stream-1 but not in stream-2?" -QUESTION_TWO = "Which numbers are present in stream-2 but not in stream-1?" +QUESTION_ONE = "Which number is present in stream-1 but not in stream-2?" +QUESTION_TWO = "Which number is present in stream-2 but not in stream-1?" FILE_PATH = "data.txt" BRANCH_1 = "stream-1" From a63e7cc9b62aa84e64db23cbc1139a1e3039cc6b Mon Sep 17 00:00:00 2001 From: lavanyagarg112 Date: Sat, 8 Nov 2025 20:23:11 +0800 Subject: [PATCH 11/14] modify verify --- branch_compare/verify.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/branch_compare/verify.py b/branch_compare/verify.py index 690a757..8a97d05 100644 --- a/branch_compare/verify.py +++ b/branch_compare/verify.py @@ -25,8 +25,8 @@ def get_branch_diff(exercise: GitAutograderExercise, branch1: str, branch2: str) exercise.repo.branches.branch("main").checkout() - set1 = set(contents1.splitlines()) - set2 = set(contents2.splitlines()) + set1 = {line.strip() for line in contents1.splitlines() if line.strip()} + set2 = {line.strip() for line in contents2.splitlines() if line.strip()} diff = set1 - set2 return str(diff.pop()) From 43d1034be0cc2d37d29f116bee9975127c16e400 Mon Sep 17 00:00:00 2001 From: lavanyagarg112 Date: Sat, 8 Nov 2025 20:45:51 +0800 Subject: [PATCH 12/14] add check for changes made to the branch --- branch_compare/res/answers.txt | 4 +-- branch_compare/tests/test_verify.py | 3 +++ branch_compare/verify.py | 42 +++++++++++++++++++++++++++-- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/branch_compare/res/answers.txt b/branch_compare/res/answers.txt index 1f2dbf8..34cb99b 100644 --- a/branch_compare/res/answers.txt +++ b/branch_compare/res/answers.txt @@ -1,5 +1,5 @@ -Q: Which number is present in stream-1 but not in stream-2? +Q: Which number is present in branch stream-1 but not in branch stream-2? A: -Q: Which number is present in stream-2 but not in stream-1? +Q: Which number is present in branch stream-2 but not in branch stream-1? A: diff --git a/branch_compare/tests/test_verify.py b/branch_compare/tests/test_verify.py index 421dabf..5076c30 100644 --- a/branch_compare/tests/test_verify.py +++ b/branch_compare/tests/test_verify.py @@ -11,6 +11,7 @@ def test_base(): with ( + patch("branch_compare.verify.has_made_changes", return_value=False), patch("branch_compare.verify.get_stream1_diff", return_value="12345"), patch("branch_compare.verify.get_stream2_diff", return_value="98765"), loader.load( @@ -26,6 +27,7 @@ def test_base(): def test_wrong_stream1_diff(): with ( + patch("branch_compare.verify.has_made_changes", return_value=False), patch("branch_compare.verify.get_stream1_diff", return_value="99999"), patch("branch_compare.verify.get_stream2_diff", return_value="98765"), loader.load( @@ -45,6 +47,7 @@ def test_wrong_stream1_diff(): def test_wrong_stream2_diff(): with ( + patch("branch_compare.verify.has_made_changes", return_value=False), patch("branch_compare.verify.get_stream1_diff", return_value="12345"), patch("branch_compare.verify.get_stream2_diff", return_value="99999"), loader.load( diff --git a/branch_compare/verify.py b/branch_compare/verify.py index 8a97d05..5213db1 100644 --- a/branch_compare/verify.py +++ b/branch_compare/verify.py @@ -7,13 +7,46 @@ from git_autograder.answers.rules import HasExactValueRule, NotEmptyRule -QUESTION_ONE = "Which number is present in stream-1 but not in stream-2?" -QUESTION_TWO = "Which number is present in stream-2 but not in stream-1?" +QUESTION_ONE = "Which number is present in branch stream-1 but not in branch stream-2?" +QUESTION_TWO = "Which number is present in branch stream-2 but not in branch stream-1?" FILE_PATH = "data.txt" BRANCH_1 = "stream-1" BRANCH_2 = "stream-2" +EXPECTED_STREAM_COMMIT_MSG = "Add data to data.txt" +EXPECTED_PREP_COMMIT_MSG = "Add empty data.txt" + +def has_made_changes(exercise: GitAutograderExercise) -> bool: + repo = exercise.repo.repo + + if repo.is_dirty(index=True, working_tree=True, untracked_files=True, submodules=True): + return True + + for bname in (BRANCH_1, BRANCH_2): + + if not exercise.repo.branches.has_branch(bname): + return True + + exercise.repo.branches.branch(bname).checkout() + try: + head = repo.head.commit + except Exception: + return True + + if head.message.strip() != EXPECTED_STREAM_COMMIT_MSG: + return True + + if len(head.parents) != 1: + return True + + parent = head.parents[0] + if parent.message.strip() != EXPECTED_PREP_COMMIT_MSG: + return True + + return False + + def get_branch_diff(exercise: GitAutograderExercise, branch1: str, branch2: str) -> str: exercise.repo.branches.branch(branch1).checkout() with exercise.repo.files.file(FILE_PATH) as f1: @@ -38,6 +71,11 @@ def get_stream2_diff(exercise: GitAutograderExercise) -> str: def verify(exercise: GitAutograderExercise) -> GitAutograderOutput: + if has_made_changes(exercise): + return exercise.to_output(["No changes are supposed to be made to the two branches in this exercise"], GitAutograderStatus.UNSUCCESSFUL) + + exercise.repo.branches.branch("main").checkout() + ans_1 = get_stream1_diff(exercise) ans_2 = get_stream2_diff(exercise) From dee23e0bb3a33481724d817a66130f31e870bec1 Mon Sep 17 00:00:00 2001 From: lavanyagarg112 Date: Sat, 8 Nov 2025 22:26:19 +0800 Subject: [PATCH 13/14] update has made changes --- branch_compare/verify.py | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/branch_compare/verify.py b/branch_compare/verify.py index 5213db1..bc854aa 100644 --- a/branch_compare/verify.py +++ b/branch_compare/verify.py @@ -14,38 +14,20 @@ BRANCH_1 = "stream-1" BRANCH_2 = "stream-2" -EXPECTED_STREAM_COMMIT_MSG = "Add data to data.txt" -EXPECTED_PREP_COMMIT_MSG = "Add empty data.txt" - def has_made_changes(exercise: GitAutograderExercise) -> bool: repo = exercise.repo.repo - - if repo.is_dirty(index=True, working_tree=True, untracked_files=True, submodules=True): - return True for bname in (BRANCH_1, BRANCH_2): - if not exercise.repo.branches.has_branch(bname): + print("No Branch") return True - exercise.repo.branches.branch(bname).checkout() - try: - head = repo.head.commit - except Exception: - return True - - if head.message.strip() != EXPECTED_STREAM_COMMIT_MSG: - return True - + head = repo.commit(bname) if len(head.parents) != 1: + print("More than one commit") return True - - parent = head.parents[0] - if parent.message.strip() != EXPECTED_PREP_COMMIT_MSG: - return True - - return False + return False def get_branch_diff(exercise: GitAutograderExercise, branch1: str, branch2: str) -> str: exercise.repo.branches.branch(branch1).checkout() From 8d4e276e12aeb7586a2bdb54f13496ded8edf0ca Mon Sep 17 00:00:00 2001 From: lavanyagarg112 Date: Sat, 8 Nov 2025 22:35:04 +0800 Subject: [PATCH 14/14] remove debug statements --- branch_compare/verify.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/branch_compare/verify.py b/branch_compare/verify.py index bc854aa..3815bd5 100644 --- a/branch_compare/verify.py +++ b/branch_compare/verify.py @@ -19,12 +19,10 @@ def has_made_changes(exercise: GitAutograderExercise) -> bool: for bname in (BRANCH_1, BRANCH_2): if not exercise.repo.branches.has_branch(bname): - print("No Branch") return True head = repo.commit(bname) if len(head.parents) != 1: - print("More than one commit") return True return False