@@ -89,24 +89,24 @@ jobs:
89
89
// Update PR title with prefix
90
90
const selectedLabel = [...shouldHaveLabels][0];
91
91
if (selectedLabel) {
92
- const prefix = titlePrefixMappings[selectedLabel];
92
+ const prefix = titlePrefixMappings[selectedLabel].toLowerCase() ;
93
93
let currentTitle = context.payload.pull_request.title;
94
94
95
95
// 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*(.*) /);
97
97
98
98
if (prefixMatch) {
99
- const currentPrefix = prefixMatch[1].toLowerCase() ;
99
+ const titleContent = prefixMatch[2] ;
100
100
// Only update if current prefix is not the correct one
101
+ const currentPrefix = prefixMatch[1].toLowerCase();
101
102
if (!validPrefixes.includes(currentPrefix) || currentPrefix !== prefix) {
102
- currentTitle = currentTitle.replace(/^[a-zA-Z]+:\s*/, '');
103
- const newTitle = `${prefix} : ${currentTitle}`;
103
+ const newTitle = `${prefix} : ${titleContent}`;
104
104
105
105
await github.rest.pulls.update({
106
106
owner : context.repo.owner,
107
107
repo : context.repo.repo,
108
108
pull_number : context.payload.pull_request.number,
109
- title : newTitle.toLowerCase()
109
+ title : newTitle
110
110
});
111
111
}
112
112
} else {
@@ -117,7 +117,7 @@ jobs:
117
117
owner : context.repo.owner,
118
118
repo : context.repo.repo,
119
119
pull_number : context.payload.pull_request.number,
120
- title : newTitle.toLowerCase()
120
+ title : newTitle
121
121
});
122
122
}
123
123
}
0 commit comments