1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-27 08:21:03 +02:00

Tools: Fixed git-changelog logic

This commit is contained in:
Laurent Cozic 2023-05-03 12:47:40 +01:00
parent 36c121523a
commit efd9f740ca
2 changed files with 8 additions and 4 deletions

View File

@ -37,6 +37,7 @@ describe('git-changelog', () => {
['Update typescript-eslint monorepo to v5 (#7291)', 'typescript-eslint', 'v5'],
['Update aws-sdk-js-v3 monorepo to v3.215.0', 'aws-sdk-js-v3', 'v3.215.0'],
['Update dependency moment to v2.29.4 (#7087)', 'moment', 'v2.29.4'],
['Update aws (#8106)', 'aws', ''],
];
for (const testCase of testCases) {
@ -59,8 +60,9 @@ describe('git-changelog', () => {
{ package: 'sas', version: 'v1.2' },
{ package: 'moment', version: 'v3.4' },
{ package: 'eslint', version: 'v1.2' },
{ package: 'aws', version: '' },
],
'Updated packages moment (v3.4), sas (v1.2)',
'Updated packages aws, moment (v3.4), sas (v1.2)',
],
[
[

View File

@ -130,6 +130,7 @@ export const parseRenovateMessage = (message: string): RenovateMessage => {
const regexes = [
/^Update dependency ([^\s]+) to ([^\s]+)/,
/^Update ([^\s]+) monorepo to ([^\s]+)/,
/^Update ([^\s]+)/,
];
for (const regex of regexes) {
@ -138,7 +139,7 @@ export const parseRenovateMessage = (message: string): RenovateMessage => {
if (m) {
return {
package: m[1],
version: m[2],
version: m.length >= 3 ? m[2] : '',
};
}
}
@ -172,7 +173,7 @@ export const summarizeRenovateMessages = (messages: RenovateMessage[]): string =
const temp: Record<string, string> = {};
for (const message of messages) {
if (!temp[message.package]) {
if (!(message.package in temp)) {
temp[message.package] = message.version;
} else {
if (message.version > temp[message.package]) {
@ -183,7 +184,8 @@ export const summarizeRenovateMessages = (messages: RenovateMessage[]): string =
const temp2: string[] = [];
for (const [pkg, version] of Object.entries(temp)) {
temp2.push(`${pkg} (${version})`);
const versionString = version ? ` (${version})` : '';
temp2.push(`${pkg}${versionString}`);
}
temp2.sort();