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

feat: commitMessageLowerCase #20930

Merged
merged 12 commits into from May 13, 2023
6 changes: 6 additions & 0 deletions lib/config/options/index.ts
Expand Up @@ -1514,6 +1514,12 @@ const options: RenovateOptions[] = [
type: 'string',
default: 'deps',
},
{
name: 'commitMessageLowerCase',
description: 'Lowercase PR- and commit titles.',
type: 'string',
default: 'auto',
kingcrunch marked this conversation as resolved.
Show resolved Hide resolved
},
// PR Behaviour
{
name: 'rollbackPrs',
Expand Down
1 change: 1 addition & 0 deletions lib/config/types.ts
Expand Up @@ -77,6 +77,7 @@ export interface RenovateSharedConfig {
automergeSchedule?: string[];
semanticCommits?: 'auto' | 'enabled' | 'disabled';
semanticCommitScope?: string | null;
commitMessageLowerCase?: string | null;
kingcrunch marked this conversation as resolved.
Show resolved Hide resolved
semanticCommitType?: string;
suppressNotifications?: string[];
timezone?: string;
Expand Down
8 changes: 6 additions & 2 deletions lib/modules/platform/azure/index.ts
Expand Up @@ -301,11 +301,15 @@
const prs = await getPrList();

prsFiltered = prs.filter(
(item) => item.sourceRefName === getNewBranchName(branchName)
rarkins marked this conversation as resolved.
Show resolved Hide resolved
(item) =>
item.sourceRefName.toLowerCase() ===

Check failure on line 305 in lib/modules/platform/azure/index.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

'item.sourceRefName' is possibly 'undefined'.

Check failure on line 305 in lib/modules/platform/azure/index.ts

View workflow job for this annotation

GitHub Actions / lint

'item.sourceRefName' is possibly 'undefined'.
getNewBranchName(branchName).toLowerCase()

Check failure on line 306 in lib/modules/platform/azure/index.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Object is possibly 'undefined'.

Check failure on line 306 in lib/modules/platform/azure/index.ts

View workflow job for this annotation

GitHub Actions / lint

Object is possibly 'undefined'.
);

if (prTitle) {
prsFiltered = prsFiltered.filter((item) => item.title === prTitle);
prsFiltered = prsFiltered.filter(
(item) => item.title.toLowerCase() === prTitle.toLowerCase()
kingcrunch marked this conversation as resolved.
Show resolved Hide resolved
);
}

switch (state) {
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/platform/bitbucket-server/index.ts
Expand Up @@ -286,8 +286,8 @@ function matchesState(state: string, desiredState: string): boolean {
const isRelevantPr =
(branchName: string, prTitle: string | null | undefined, state: string) =>
(p: Pr): boolean =>
p.sourceBranch === branchName &&
(!prTitle || p.title === prTitle) &&
p.sourceBranch.toLowerCase() === branchName.toLowerCase() &&
kingcrunch marked this conversation as resolved.
Show resolved Hide resolved
(!prTitle || p.title.toLowerCase() === prTitle.toLowerCase()) &&
matchesState(p.state, state);

// TODO: coverage (#9624)
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/platform/bitbucket/index.ts
Expand Up @@ -290,8 +290,8 @@ export async function findPr({
const prList = await getPrList();
const pr = prList.find(
(p) =>
p.sourceBranch === branchName &&
(!prTitle || p.title === prTitle) &&
p.sourceBranch.toLowerCase() === branchName.toLowerCase() &&
(!prTitle || p.title.toLowerCase() === prTitle.toLowerCase()) &&
matchesState(p.state, state)
);
if (pr) {
Expand Down
7 changes: 5 additions & 2 deletions lib/modules/platform/codecommit/index.ts
Expand Up @@ -202,11 +202,14 @@
const prs = await getPrList();
const refsHeadBranchName = getNewBranchName(branchName);
prsFiltered = prs.filter(
(item) => item.sourceBranch === refsHeadBranchName
(item) =>
item.sourceBranch.toLowerCase() === refsHeadBranchName.toLowerCase()

Check failure on line 206 in lib/modules/platform/codecommit/index.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

'refsHeadBranchName' is possibly 'undefined'.

Check failure on line 206 in lib/modules/platform/codecommit/index.ts

View workflow job for this annotation

GitHub Actions / lint

'refsHeadBranchName' is possibly 'undefined'.
);

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

switch (state) {
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/platform/github/index.ts
Expand Up @@ -712,11 +712,11 @@ export async function findPr({
logger.debug(`findPr(${branchName}, ${prTitle}, ${state})`);
const prList = await getPrList();
const pr = prList.find((p) => {
if (p.sourceBranch !== branchName) {
if (p.sourceBranch.toLowerCase() !== branchName.toLowerCase()) {
return false;
}

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

Expand Down
4 changes: 2 additions & 2 deletions lib/modules/platform/gitlab/index.ts
Expand Up @@ -749,8 +749,8 @@ export async function findPr({
return (
prList.find(
(p: { sourceBranch: string; title: string; state: string }) =>
p.sourceBranch === branchName &&
(!prTitle || p.title === prTitle) &&
p.sourceBranch.toLowerCase() === branchName.toLowerCase() &&
(!prTitle || p.title.toLowerCase() === prTitle.toLowerCase()) &&
matchesState(p.state, state)
) ?? null
);
Expand Down
7 changes: 2 additions & 5 deletions lib/workers/repository/updates/generate.ts
Expand Up @@ -200,9 +200,6 @@ export function generateBranchConfig(
)})`;
}
upgrade.commitMessagePrefix = CommitMessage.formatPrefix(semanticPrefix!);
upgrade.toLowerCase =
regEx(/[A-Z]/).exec(upgrade.semanticCommitType!) === null &&
!upgrade.semanticCommitType!.startsWith(':');
}

// Compile a few times in case there are nested templates
Expand All @@ -226,7 +223,7 @@ export function generateBranchConfig(
regEx(/to vv(\d)/),
'to v$1'
);
if (upgrade.toLowerCase) {
if (upgrade.commitMessageLowerCase === 'auto') {
kingcrunch marked this conversation as resolved.
Show resolved Hide resolved
// We only need to lowercase the first line
const splitMessage = upgrade.commitMessage.split(newlineRegex);
splitMessage[0] = splitMessage[0].toLowerCase();
Expand All @@ -249,7 +246,7 @@ export function generateBranchConfig(
);
throw new Error(CONFIG_SECRETS_EXPOSED);
}
if (upgrade.toLowerCase) {
if (upgrade.commitMessageLowerCase === 'auto') {
upgrade.prTitle = upgrade.prTitle.toLowerCase();
}
} else {
Expand Down