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

Fix commitPrefix setting with empty pattern #4381

Merged
merged 2 commits into from
Mar 12, 2025

Conversation

stefanhaller
Copy link
Collaborator

Before we changed the commitPrefix config to a list in #4261, we had this bug where the defaults section in Config.md would erroneously list the default for commitPrefix as

  git:
    commitPrefix:
      pattern: ""
      replace: ""

This was not correct, commitPrefix was a pointer, and the default for that was nil, which is not the same.

Now, some people copied and pasted the entire defaults section into their config files, setting the commitPrefix to an empty pattern (which is not the same as not setting it at all). And this caused the branch name to be filled in to the subject field for every commit; see for example #3632.

New users copying the defaults section into their config file in the current version no longer have this problem because now that commitPrefix is a list, it is no longer included in the defaults section. However, the migration that we added in #4261 would happily carry over those empty strings into a list entry, so people migrating from an older version still have the broken config in their config files.

To work around the issue, ignore commit prefix settings whose pattern is an empty string. I can't imagine a valid reason why people would actually want to set the pattern to an empty string, so I assume this only comes from the broken defaults problem described above.

@stefanhaller stefanhaller added the bug Something isn't working label Mar 9, 2025
Copy link

codacy-production bot commented Mar 9, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for c735a5e1 50.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (c735a5e) Report Missing Report Missing Report Missing
Head commit (05a18ed) 53203 46084 86.62%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#4381) 2 1 50.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

Before we changed the commitPrefix config to a list in #4261, we had this bug
where the defaults section in Config.md would erroneously list the default for
commitPrefix as

  git:
    commitPrefix:
      pattern: ""
      replace: ""

This was not correct, commitPrefix was a pointer, and the default for that was
nil, which is not the same.

Now, some people copied and pasted the entire defaults section into their config
files, setting the commitPrefix to an empty pattern (which is not the same as
not setting it at all). And this caused the branch name to be filled in to the
subject field for every commit; see for example
#3632.

New users copying the defaults section into their config file in the current
version no longer have this problem because now that commitPrefix is a list, it
is no longer included in the defaults section. However, the migration that we
added in #4261 would happily carry over those empty strings into a list entry,
so people migrating from an older version still have the broken config in their
config files.

To work around the issue, ignore commit prefix settings whose pattern is an
empty string. I can't imagine a valid reason why people would actually want to
set the pattern to an empty string, so I assume this only comes from the broken
defaults problem described above.
I'm not mentioning *why* it's not a good idea, and I'm not sure it's important
to explain this to users. I'll say it here:
- it exposes users to potential bugs like the one described in the previous
  commit
- if we decide to change the default of an option to something "better" (like we
  did with the "show graph" setting), users don't benefit from what we think is
  an improvement for most users
@stefanhaller stefanhaller force-pushed the fix-commit-prefix-with-empty-pattern branch from e8c58cb to 05a18ed Compare March 12, 2025 07:15
@stefanhaller stefanhaller enabled auto-merge March 12, 2025 07:16
@stefanhaller stefanhaller merged commit a0dd3be into master Mar 12, 2025
15 checks passed
@stefanhaller stefanhaller deleted the fix-commit-prefix-with-empty-pattern branch March 12, 2025 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants