diff --git a/.hooks/pre_commit_hooks/check_conditional_mark_sort.py b/.hooks/pre_commit_hooks/check_conditional_mark_sort.py index fac50d255f1..2c1f480b726 100755 --- a/.hooks/pre_commit_hooks/check_conditional_mark_sort.py +++ b/.hooks/pre_commit_hooks/check_conditional_mark_sort.py @@ -4,7 +4,6 @@ def main(): stage_files = sys.argv[1:] - retval = 0 for stage_file in stage_files: if "tests_mark_conditions" in stage_file: conditions = [] @@ -17,11 +16,21 @@ def main(): conditions.append(line.strip().rstrip(":")) sorted_conditions = conditions[:] sorted_conditions.sort() - if conditions != sorted_conditions: - print("The entries in tests/common/plugins/conditional_mark/tests_mark_conditions*.yaml " - "are not sorted in alphabetic order.") - retval = 1 - return retval + for i in range(len(conditions)): + if conditions[i] != sorted_conditions[i]: + print("The entries in tests/common/plugins/conditional_mark/tests_mark_conditions*.yaml " + "are not sorted in alphabetic order, please adjust the order before commit") + print("===========================================================================") + print("File: {}".format(stage_file)) + print("===========================================================================") + print("Conditional marks before sort: {}".format(conditions)) + print("Conditional marks after sort: {}".format(sorted_conditions)) + print("===========================================================================") + print("Mismatch item, before sort: {}, after sort: {}".format(conditions[i], + sorted_conditions[i])) + print("===========================================================================") + return 1 + return 0 if __name__ == "__main__":