1111DETACHED_HEAD = "You should not be in a detached HEAD state! Use git checkout main to get back to main"
1212MISSING_MERGES = "You are missing some merges"
1313NO_MERGES = "You need to start merging the feature branches."
14+ NO_FAST_FORWARDING = "You cannot use fast forwarding on {branch_name} when merging."
1415WRONG_MERGE_ORDER = "You should have merged {branch_name} first. The expected order is feature/login, then feature/dashboard, and last feature/payments"
1516FEATURE_LOGIN_MERGE_MISSING = "You should have merged feature/login first."
1617FEATURE_DASHBOARD_MERGE_MISSING = "You should have merged feature/dashboard next."
@@ -31,6 +32,7 @@ def verify(exercise: GitAutograderExercise) -> GitAutograderOutput:
3132
3233 main_reflog = main_branch .reflog
3334 merge_logs = [entry for entry in main_reflog if entry .action .startswith ("merge" )]
35+ messages = [entry .message for entry in merge_logs ][::- 1 ]
3436 merge_order = [entry .action [len ("merge " ) :] for entry in merge_logs ][::- 1 ]
3537
3638 if len (merge_order ) == 0 :
@@ -42,12 +44,27 @@ def verify(exercise: GitAutograderExercise) -> GitAutograderOutput:
4244 if merge_order [0 ] != "feature/login" :
4345 raise exercise .wrong_answer ([FEATURE_LOGIN_MERGE_MISSING , RESET_MESSAGE ])
4446
47+ if messages [0 ] == "Fast-forward" :
48+ raise exercise .wrong_answer (
49+ [NO_FAST_FORWARDING .format (branch_name = "feature/login" ), RESET_MESSAGE ]
50+ )
51+
4552 if merge_order [1 ] != "feature/dashboard" :
4653 raise exercise .wrong_answer ([FEATURE_DASHBOARD_MERGE_MISSING , RESET_MESSAGE ])
4754
55+ if messages [1 ] == "Fast-forward" :
56+ raise exercise .wrong_answer (
57+ [NO_FAST_FORWARDING .format (branch_name = "feature/dashboard" ), RESET_MESSAGE ]
58+ )
59+
4860 if merge_order [2 ] != "feature/payments" :
4961 raise exercise .wrong_answer ([FEATURE_PAYMENTS_MERGE_MISSING , RESET_MESSAGE ])
5062
63+ if messages [2 ] == "Fast-forward" :
64+ raise exercise .wrong_answer (
65+ [NO_FAST_FORWARDING .format (branch_name = "feature/payments" ), RESET_MESSAGE ]
66+ )
67+
5168 return exercise .to_output (
5269 [
5370 "Great work with merging the branches in order! Try running the HTML files locally!"
0 commit comments