Skip to content

Commit 64154c7

Browse files
committed
[mix-messy-graph] Fix merge commit check
1 parent 96d233f commit 64154c7

File tree

3 files changed

+68
-6
lines changed

3 files changed

+68
-6
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
initialization:
2+
steps:
3+
- type: commit
4+
empty: true
5+
message: Add features.md
6+
id: start
7+
- type: commit
8+
empty: true
9+
message: Mention feature for creating books
10+
- type: tag
11+
tag-name: v1.0
12+
- type: commit
13+
empty: true
14+
message: Fix phrasing of heading
15+
16+
- type: branch
17+
branch-name: feature-search
18+
- type: commit
19+
empty: true
20+
message: Feature search
21+
- type: checkout
22+
branch-name: main
23+
- type: merge
24+
branch-name: feature-search
25+
no-ff: true
26+
27+
- type: commit
28+
empty: true
29+
message: Add the delete feature
30+
31+
- type: new-file
32+
filename: features.md
33+
contents: |
34+
# Features
35+
36+
## Create Book
37+
38+
Allows creating one book at a time.
39+
40+
## Searching for Books
41+
42+
Allows searching for books by keywords.
43+
Works only for book titles.
44+
45+
## Deleting Books
46+
47+
Allows deleting books.

mix_messy_graph/tests/test_verify.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from git_autograder import GitAutograderStatus, GitAutograderTestLoader, assert_output
22

33
from ..verify import (
4-
FEATURE_SEARCH_BRANCH_STILL_EXISTS,
54
FEATURE_DELETE_BRANCH_STILL_EXISTS,
5+
FEATURE_SEARCH_BRANCH_STILL_EXISTS,
66
FEATURES_FILE_CONTENT_INVALID,
77
LIST_BRANCH_STILL_EXISTS,
88
MISMATCH_COMMIT_MESSAGE,
@@ -22,7 +22,25 @@ def test_base():
2222

2323
def test_non_squash_merge_used():
2424
with loader.load("specs/non_squash_merge_used.yml") as output:
25-
assert_output(output, GitAutograderStatus.UNSUCCESSFUL, [SQUASH_NOT_USED])
25+
# This would fail because the squash merge changes the commit messages and the contents
26+
assert_output(
27+
output,
28+
GitAutograderStatus.UNSUCCESSFUL,
29+
[
30+
MISMATCH_COMMIT_MESSAGE.format(
31+
expected="Add the search feature", given="Feature search"
32+
)
33+
],
34+
)
35+
36+
37+
def test_non_squash_merge_used_2():
38+
with loader.load("specs/non_squash_merge_used_2.yml") as output:
39+
assert_output(
40+
output,
41+
GitAutograderStatus.UNSUCCESSFUL,
42+
[SQUASH_NOT_USED],
43+
)
2644

2745

2846
def test_wrong_commit_message():

mix_messy_graph/verify.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ def ensure_str(val) -> str:
5555
def verify(exercise: GitAutograderExercise) -> GitAutograderOutput:
5656
main_branch = exercise.repo.branches.branch("main")
5757
merge_commits = [c for c in main_branch.commits if len(c.parents) > 1]
58-
merge_reflogs = [e for e in main_branch.reflog if "merge" in e.action]
59-
# We expect 1 merge reflog entry because of the setup step which merges the branch,
60-
# but no other merges should be present
61-
if merge_commits or len(merge_reflogs) > 1:
58+
if merge_commits:
6259
raise exercise.wrong_answer([SQUASH_NOT_USED])
6360

6461
commit_messages = [ensure_str(c.commit.message) for c in main_branch.commits][::-1]

0 commit comments

Comments
 (0)