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: lowercase first word of commit message #12440
fix: lowercase first word of commit message #12440
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs more tests added. I think you'll find it doesn't work as expected. e.g. we should test:
fix: Upgrade something
, fix(docs): Something else
, Really great feature: Foo
, etc.
const splitMessage = upgrade.commitMessage.split('\n'); | ||
splitMessage[0] = splitMessage[0].toLowerCase(); | ||
splitMessage[0] = splitMessage[0].replace( | ||
splitMessage[0].includes(':') ? regEx(/: \w+/) : regEx(/^\w+/), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is accurate enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be done in commit message builder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
str = str.replace(
str.includes(':') ? /.*: \w+/ : /^\w+/,
(match) => match.toLowerCase()
);
This snippet works fine for the all the cases except Really great feature: Foo
, for this type of message it lowercases the whole string which is a problem. Isn't such a commit message valid, cause it violates the good-commit-message rules?
Regarding the accuracy of the regex, we are only targeting the sub-string we want to lowercase
/.*: \w/
-> It will look for a semi-colon and a word after it (i.e first word of message)
-Eg.fix: Upgrade something
for this our match isfix: Upgrade
/^\w/
-> It matches first word of the message.
-Eg.Upgrade Something Please
-> It matchesUpgrade
.
Also I was wondering what would be the updated commit message for Really great feature: Foo
really great feature: Foo
or,really great feature: foo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i still suggest to move the whole logic to this file:
As we build the message there, so it should be more easily to fix it there for all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@viceice I am not sure where the changes need to be updated in the new file, could you please guide me by commenting on the file where the certain functionalities needs to be added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RahulGautamSingh I guess in general would be nice if BranchUpgradeConfig
interface will have instance of CommitMessage
class. Therefore need to refactor lib/workers/repository/updates/generate.ts
to using this class. During this refactoring maybe will be required extend functionality of CommitMessage
or create inherited class for specific purposes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the help @pret-a-porter . Seems that I need to go through the code and refactor it. I am closing this PR for now and will create a new one when I have updated the code.
Hey @rarkins ,once you give the above suggestion by @pret-a-porter a 👍 I will start my work.
Changes:
Updated code so that only first word of commit messages and prTitle is lowercased instead of the whole message.
Context:
Closes #12062
Documentation (please check one with an [x])
How I've tested my work (please tick one)
I have verified these changes via: