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

"Subject not capitalized" error on some environments when subject is capitalized #1

Closed
laurivan opened this issue Jun 11, 2024 · 0 comments

Comments

@laurivan
Copy link
Owner

Description

On some systems the subject of a commit message is erroneously reported as not being capitalized.

$ git commit -m "Version update"
ERROR: commit message not properly formatted
- line 1: subject not capitalized
  Version update

Continue anyway? [yes/no/edit] no

Cause

I don't know which systems or environments are affected but it seems that the problem is matching the subject line with a regular expression that uses a "traditional" character range:

[[ ${subject} =~ ^[a-z] ]]

This "usually" works but is dependent on at least the user's locale, especially the LC_COLLATE environment variable which can change what [a-z] means. On some systems it might mean [aAbBcC...] instead of the expected [abcd...] which makes it match uppercase letters as well.

Fix

The fix is as simple as replacing [a-z] in the regex with [[:lower:]] which is always interpreted as [abc...xyz]

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

No branches or pull requests

1 participant