Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(check): Add --allow-abort option #512

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
Lee-W merged 3 commits into commitizen-tools:master from Kurt-von-Laven:reject-abort
May 14, 2022

Conversation

Copy link
Contributor

@Kurt-von-Laven Kurt-von-Laven commented May 5, 2022
edited
Loading

Description

Empty commit messages indicate to Git that the commit should be aborted. Displaying an error message when the commit is already being aborted typically only creates confusion. Add an --allow-abort argument to the check command and allow_abort config variable, both defaulting to false for backwards compatibility. When the commit message is empty, determine the outcome based on the allow_abort setting alone, ignoring the pattern.

Closes #424.

Checklist

  • Add test cases to all the changes you introduce
  • Run ./scripts/format and ./scripts/test locally to ensure this change passes linter check and test
  • Test the changes on the local machine manually
  • Update the documentation for the changes

Expected behavior

No error message is displayed when aborting a commit locally, unless the commit .

Steps to Test This Pull Request

  1. Run cz commit.
  2. Save and close the commit message file that appears with an empty commit message.
  3. No error occurs if you add allow_abort = true to your config, but an error occurs otherwise.

Additional context

Would it make sense for --allow-abort to also be added as an arg to the commit command? How do folks feel about the argument/setting name and overall approach? See also #247 for a related feature proposal. Since the time of that discussion, I realized that naming a Commitizen argument --allow-empty-message could prove extremely confusing, because passing it to Commitizen would not, by itself, cause commits with empty messages to be committed like the Git argument of the same name. It would also interact poorly with the proposal to allow ferrying arbitrary arguments to git commit in #451, because it would be easy to accidentally pass the argument to Git, resulting in commits with empty messages no longer being aborted.

@Kurt-von-Laven Kurt-von-Laven force-pushed the reject-abort branch 4 times, most recently from 8199666 to cd8c895 Compare May 5, 2022 07:32
Copy link

codecov bot commented May 5, 2022
edited
Loading

Codecov Report

Merging #512 (aa25391) into master (7b69599) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@ Coverage Diff @@
## master #512 +/- ##
=======================================
 Coverage 97.92% 97.92% 
=======================================
 Files 39 39 
 Lines 1540 1543 +3 
=======================================
+ Hits 1508 1511 +3 
 Misses 32 32 
Flag Coverage Δ
unittests 97.92% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
commitizen/cli.py 93.93% <ø> (ø)
commitizen/__version__.py 100.00% <100.00%> (ø)
commitizen/commands/check.py 100.00% <100.00%> (ø)
commitizen/cz/__init__.py 100.00% <100.00%> (ø)
commitizen/defaults.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 713ce19...aa25391. Read the comment docs.

@woile woile requested a review from Lee-W May 10, 2022 11:55
Copy link
Member

woile commented May 10, 2022

LGTM but cz check is not my speciality, can u take a look @Lee-W ?

Lee-W reacted with thumbs up emoji

Copy link
Member

@Lee-W Lee-W left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Kurt-von-Laven , sorry for late reviewing. Your work is fantastic! Just left a few questions. But I think we're almost ready to mrege

@Kurt-von-Laven Kurt-von-Laven changed the title (削除) feat(check): Don't error on empty commit messages (削除ここまで) (追記) feat(check): Add --allow-abort option (追記ここまで) May 11, 2022
Copy link
Contributor Author

@Kurt-von-Laven Kurt-von-Laven left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense for --allow-abort to also be added as an arg to the commit command?

EDIT: I think I answered this question for myself: no.

Copy link
Contributor Author

I am not able to reproduce the failure on Python 3.10 locally on Python 3.10.4. It appears to be unrelated to this pull request, so I think the build may simply need to be re-run. Please let me know if anyone sees a connection I am missing.

Copy link
Member

@Lee-W Lee-W left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except for the minor comment update, this PR looks good to me. @woile I'm planning on merging it this weekend if no other new comments added

woile reacted with thumbs up emoji
Copy link
Member

Lee-W commented May 13, 2022

hmmm. we might need to take a deeper look at the 3.10 case

Empty commit messages indicate to Git that the commit should be aborted.
Displaying an error message when the commit is already being aborted
typically only creates confusion. Add an --allow-abort argument to the
check command and allow_abort config variable, both defaulting to false
for backwards compatibility. When the commit message is empty, determine
the outcome based on the allow_abort setting alone, ignoring the
pattern.
Copy link
Contributor Author

@Kurt-von-Laven Kurt-von-Laven left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still unable to reproduce the build failure locally on Python 3.10.4.

Copy link
Contributor Author

Looks like the Python 3.10 build indeed simply needed to be re-run since all I changed was the two comments.

Lee-W reacted with thumbs up emoji

Copy link
Member

@Lee-W Lee-W left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Let's merge it now!

Kurt-von-Laven reacted with hooray emoji
@Lee-W Lee-W merged commit e0f9fe5 into commitizen-tools:master May 14, 2022
@Kurt-von-Laven Kurt-von-Laven deleted the reject-abort branch May 14, 2022 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@Lee-W Lee-W Lee-W approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Aborted Commit Considered to Fail Validation When Run As commit-msg Hook

AltStyle によって変換されたページ (->オリジナル) /