Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions conventional_precommit_linter/hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ def get_allowed_scopes(args: argparse.Namespace) -> List[str]:
def read_commit_message(file_path: str) -> str:
with open(file_path, encoding='utf-8') as file:
lines = file.readlines()

scissor_line_index = None
for i, line in enumerate(lines):
if line.strip() == '# ------------------------ >8 ------------------------':
scissor_line_index = i
break

if scissor_line_index is not None:
lines = lines[:scissor_line_index]

lines = [line for line in lines if not line.startswith('#')] # Remove comment lines (starting with '#')
content = ''.join(lines)
if not content.strip():
Expand Down
6 changes: 6 additions & 0 deletions tests/test_custom_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,12 @@ def commit_message_id(commit_message): # pylint: disable=redefined-outer-name
{'error_summary_period': True},
get_argv_list(scope_case_insensitive_arg=True),
),
(
# Expected PASS: Message with scissor line and diff content that should be ignored
'fix(bt): Update database configuration\n\nThis change updates the database configuration for better performance.\n# Please enter the commit message for your changes.\n# Lines starting with \'#\' will be ignored.\n#\n# On branch feature-branch\n# Changes to be committed:\n#\tnew file: src/config.js\n#\tmodified: package.json\n#\n# ------------------------ >8 ------------------------\n# Do not modify or remove the line above.\n# Everything below it will be ignored.\ndiff --git a/src/config.js b/src/config.js\nnew file mode 100644\nindex 0000000..1234567\n--- /dev/null\n+++ b/src/config.js\n@@ -0,0 +1,5 @@\n+module.exports = { database: { host: "averylonglinethatwouldbreaknormallybutthisshouldbeignored" } };',
{},
get_argv_list(),
),
],
# Use the commit message to generate IDs for each test case
ids=commit_message_id,
Expand Down