Skip to content

feat: handle fixup and squash messages #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 24, 2024
Merged
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
137 changes: 0 additions & 137 deletions .flake8

This file was deleted.

2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# The global '*' pattern specifies code owners for all files in the repository.
* @tomassebestik @kumekay
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand Down
21 changes: 0 additions & 21 deletions .mypy.ini

This file was deleted.

4 changes: 4 additions & 0 deletions conventional_precommit_linter/hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ def main(argv: Optional[List[str]] = None) -> int:
message_title = message_lines[0] # The summary is the first line
message_body = message_lines[1:] # The body is everything after the summary, if it exists

# Skip message lining if the commit message is 'fixup!' or 'squash!' (will not stay in git history anyway)
if re.match(r'^(fixup|squash)', message_title):
return 0

if not check_colon_after_type(message_title):
print(f'FAIL: Missing colon after {_color_purple("<type>")} or {_color_blue("(<optional-scope>)")}.')
print(f'\nEnsure the commit message has the format "{_color_purple("<type>")}{_color_blue("(<optional-scope>)")}: {_color_orange("<summary>")}"')
Expand Down
12 changes: 12 additions & 0 deletions tests/test_custom_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,18 @@ def commit_message_id(commit_message): # pylint: disable=redefined-outer-name
{},
get_argv_list(),
),
(
# Expected PASS: FIXUP Message with scope and body
'fixup! feat(bootloader): This is fixup commit message with scope and body\n\nThis is a text of body',
{},
get_argv_list(),
),
(
# Expected PASS: SQUASH Message with scope and body
'squash! feat(bootloader): This is fixup commit message with scope and body\n\nThis is a text of body',
{},
get_argv_list(),
),
(
# Expected FAIL: Message with scope with 2 exclamation marks
'change(rom)!!: This is commit message with 2 exclamations',
Expand Down
10 changes: 10 additions & 0 deletions tests/test_default_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ def commit_message_id(commit_message): # pylint: disable=redefined-outer-name
'change(rom): this message starts with lowercase',
{},
),
(
# Expected PASS: FIXUP Message with scope and body
'fixup! feat(bootloader): This is fixup commit message with scope and body\n\nThis is a text of body',
{},
),
(
# Expected PASS: SQUASH Message with scope and body
'squash! feat(bootloader): This is fixup commit message with scope and body\n\nThis is a text of body',
{},
),
(
# Expected FAIL: Message without scope with exclamation mark
'change!: This is commit message without scope but with exclamation mark',
Expand Down
Loading