Skip to content

Commit

Permalink
feat: commitMessageLowerCase (#20930)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Co-authored-by: Rhys Arkins <rhys@arkins.net>
  • Loading branch information
3 people committed May 13, 2023
1 parent 0e27bd1 commit fc73b07
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 8 deletions.
5 changes: 5 additions & 0 deletions docs/usage/configuration-options.md
Expand Up @@ -448,6 +448,11 @@ Check out the default value for `commitMessage` to understand how this field is
This is used to alter `commitMessage` and `prTitle` without needing to copy/paste the whole string.
The "extra" is usually an identifier of the new version, e.g. "to v1.3.2" or "to tag 9.2".

## commitMessageLowerCase

With `semanticCommits` pr- and commit-titles will by default (`"auto"`) be converted to all-lowercase.
Set this to `"never"` to leave the titles untouched, allowing uppercase characters in semantic commit titles.

## commitMessagePrefix

This is used to alter `commitMessage` and `prTitle` without needing to copy/paste the whole string.
Expand Down
7 changes: 7 additions & 0 deletions lib/config/options/index.ts
Expand Up @@ -1549,6 +1549,13 @@ const options: RenovateOptions[] = [
type: 'string',
default: 'deps',
},
{
name: 'commitMessageLowerCase',
description: 'Lowercase PR- and commit titles.',
type: 'string',
allowedValues: ['auto', 'never'],
default: 'auto',
},
// PR Behaviour
{
name: 'rollbackPrs',
Expand Down
1 change: 1 addition & 0 deletions lib/config/types.ts
Expand Up @@ -78,6 +78,7 @@ export interface RenovateSharedConfig {
automergeSchedule?: string[];
semanticCommits?: 'auto' | 'enabled' | 'disabled';
semanticCommitScope?: string | null;
commitMessageLowerCase?: 'auto' | 'never';
semanticCommitType?: string;
suppressNotifications?: string[];
timezone?: string;
Expand Down
4 changes: 3 additions & 1 deletion lib/modules/platform/azure/index.ts
Expand Up @@ -307,7 +307,9 @@ export async function findPr({
);

if (prTitle) {
prsFiltered = prsFiltered.filter((item) => item.title === prTitle);
prsFiltered = prsFiltered.filter(
(item) => item.title.toUpperCase() === prTitle.toUpperCase()
);
}

switch (state) {
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/platform/bitbucket-server/index.ts
Expand Up @@ -289,7 +289,7 @@ const isRelevantPr =
(branchName: string, prTitle: string | null | undefined, state: string) =>
(p: Pr): boolean =>
p.sourceBranch === branchName &&
(!prTitle || p.title === prTitle) &&
(!prTitle || p.title.toUpperCase() === prTitle.toUpperCase()) &&
matchesState(p.state, state);

// TODO: coverage (#9624)
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/platform/bitbucket/index.ts
Expand Up @@ -293,7 +293,7 @@ export async function findPr({
const pr = prList.find(
(p) =>
p.sourceBranch === branchName &&
(!prTitle || p.title === prTitle) &&
(!prTitle || p.title.toUpperCase() === prTitle.toUpperCase()) &&
matchesState(p.state, state)
);
if (pr) {
Expand Down
4 changes: 3 additions & 1 deletion lib/modules/platform/codecommit/index.ts
Expand Up @@ -208,7 +208,9 @@ export async function findPr({
);

if (prTitle) {
prsFiltered = prsFiltered.filter((item) => item.title === prTitle);
prsFiltered = prsFiltered.filter(
(item) => item.title.toUpperCase() === prTitle.toUpperCase()
);
}

switch (state) {
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/platform/github/index.ts
Expand Up @@ -716,7 +716,7 @@ export async function findPr({
return false;
}

if (prTitle && prTitle !== p.title) {
if (prTitle && prTitle.toUpperCase() !== p.title.toUpperCase()) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/modules/platform/gitlab/index.ts
Expand Up @@ -752,7 +752,7 @@ export async function findPr({
prList.find(
(p: { sourceBranch: string; title: string; state: string }) =>
p.sourceBranch === branchName &&
(!prTitle || p.title === prTitle) &&
(!prTitle || p.title.toUpperCase() === prTitle.toUpperCase()) &&
matchesState(p.state, state)
) ?? null
);
Expand Down
4 changes: 2 additions & 2 deletions lib/workers/repository/updates/generate.ts
Expand Up @@ -226,7 +226,7 @@ export function generateBranchConfig(
regEx(/to vv(\d)/),
'to v$1'
);
if (upgrade.toLowerCase) {
if (upgrade.toLowerCase && upgrade.commitMessageLowerCase !== 'never') {
// We only need to lowercase the first line
const splitMessage = upgrade.commitMessage.split(newlineRegex);
splitMessage[0] = splitMessage[0].toLowerCase();
Expand All @@ -249,7 +249,7 @@ export function generateBranchConfig(
);
throw new Error(CONFIG_SECRETS_EXPOSED);
}
if (upgrade.toLowerCase) {
if (upgrade.toLowerCase && upgrade.commitMessageLowerCase !== 'never') {
upgrade.prTitle = upgrade.prTitle.toLowerCase();
}
} else {
Expand Down

0 comments on commit fc73b07

Please sign in to comment.