Skip to content
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

ENH: Require space and capital letter after colon in commit message first line #7341

Open
wants to merge 1 commit into
base: hooks
Choose a base branch
from

Conversation

Leengit
Copy link
Contributor

@Leengit Leengit commented Nov 3, 2023

Enforce that there be (at least) one space after BUG:, COMP:, DOC:, ENH:, PERF:, or STYLE: at the start of the first line of a commit message.

Current usage shows me the following counts in the git log for trailing spaces. In no cases were there 3 or more spaces.

     39 'BUG:  '
  11109 'BUG: '
     39 'BUG:'
     55 'COMP:  '
   6642 'COMP: '
      6 'COMP:'
      6 'DOC:  '
   1110 'DOC: '
      0 'DOC:'
     86 'ENH:  '
  16342 'ENH: '
     73 'ENH:'
      4 'PERF:  '
    225 'PERF: '
      0 'PERF:'
     14 'STYLE:  '
   3610 'STYLE: '
     11 'STYLE:'

Copy link
Contributor

@jamesobutler jamesobutler left a comment

Choose a reason for hiding this comment

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

It appears that some of these enforcements are slightly different than what is actually being enforced as a GitHub status check prior to integration.

pattern: '^(ENH|PERF|BUG|STYLE|DOC|COMP): ([A-Z])+'

pattern: '^[^#].{1,78}$'

For example this file also states printErrorAndExit 'The first line must be at least 8 characters:, but that is not included in the commit-message.yml.

I wonder if there is a better to way to keep the two areas in sync.

@jcfr
Copy link
Member

jcfr commented Nov 9, 2023

The pull-request has been rebased to include change recently integrated through:

@Leengit
Copy link
Contributor Author

Leengit commented Nov 13, 2023

I agree with @jamesobutler that we would benefit from tighter integration between the sets of checks. If it isn't already, perhaps you could add that as an issue. Should we go ahead with this pull request?

@Leengit
Copy link
Contributor Author

Leengit commented Nov 27, 2023

This latest push adds a check that both a space and a capital letter follow the colon. It also simplifies the if statement to use egrep.

@Leengit Leengit changed the title ENH: Require "ENH: " instead of "ENH:", etc. in commit message first line ENH: Require space and capital letter after colon in commit message first line Nov 27, 2023
@Leengit
Copy link
Contributor Author

Leengit commented Nov 27, 2023

Note that the checks that the line length is at least 8 and at most 78 occur earlier in the code, but could be added here with

if echo "$line" | egrep -qx '(BUG|COMP|DOC|ENH|PERF|STYLE): [A-Z].*' &&
        echo "$line" | egrep -qx '.{8,78}'; then
  # first line okay
  ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants