Skip to content

Commit 8c430be

Browse files
committed
fix to not make whole title lowercase
1 parent f6db74c commit 8c430be

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

.github/workflows/pr-title-labeler.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -89,24 +89,24 @@ jobs:
8989
// Update PR title with prefix
9090
const selectedLabel = [...shouldHaveLabels][0];
9191
if (selectedLabel) {
92-
const prefix = titlePrefixMappings[selectedLabel];
92+
const prefix = titlePrefixMappings[selectedLabel].toLowerCase();
9393
let currentTitle = context.payload.pull_request.title;
9494

9595
// Check if current title has any prefix (including non-standard ones)
96-
const prefixMatch = currentTitle.match(/^([a-zA-Z]+):\s*/);
96+
const prefixMatch = currentTitle.match(/^([a-zA-Z]+):\s*(.*)/);
9797

9898
if (prefixMatch) {
99-
const currentPrefix = prefixMatch[1].toLowerCase();
99+
const titleContent = prefixMatch[2];
100100
// Only update if current prefix is not the correct one
101+
const currentPrefix = prefixMatch[1].toLowerCase();
101102
if (!validPrefixes.includes(currentPrefix) || currentPrefix !== prefix) {
102-
currentTitle = currentTitle.replace(/^[a-zA-Z]+:\s*/, '');
103-
const newTitle = `${prefix}: ${currentTitle}`;
103+
const newTitle = `${prefix}: ${titleContent}`;
104104

105105
await github.rest.pulls.update({
106106
owner: context.repo.owner,
107107
repo: context.repo.repo,
108108
pull_number: context.payload.pull_request.number,
109-
title: newTitle.toLowerCase()
109+
title: newTitle
110110
});
111111
}
112112
} else {
@@ -117,7 +117,7 @@ jobs:
117117
owner: context.repo.owner,
118118
repo: context.repo.repo,
119119
pull_number: context.payload.pull_request.number,
120-
title: newTitle.toLowerCase()
120+
title: newTitle
121121
});
122122
}
123123
}

0 commit comments

Comments
 (0)