From b34342f01ef0e755890d38ad7eb88860e83e1c33 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Tue, 6 Jun 2023 12:04:06 +0100 Subject: [PATCH] Tools: Improve git-changelog tag detection --- packages/tools/git-changelog.ts | 9 +++++++++ packages/tools/package.json | 1 + yarn.lock | 8 ++++++++ 3 files changed, 18 insertions(+) diff --git a/packages/tools/git-changelog.ts b/packages/tools/git-changelog.ts index 975b861df..f72489da0 100644 --- a/packages/tools/git-changelog.ts +++ b/packages/tools/git-changelog.ts @@ -3,6 +3,7 @@ // (Desktop|Mobile|Android|iOS[CLI): (New|Improved|Fixed): Some message..... (#ISSUE) import { execCommand, githubUsername } from './tool-utils'; +import * as compareVersions from 'compare-versions'; interface LogEntry { message: string; @@ -197,6 +198,11 @@ export const summarizeRenovateMessages = (messages: RenovateMessage[]): string = return ''; }; +const versionFromTag = (tag: string) => { + const s = tag.split('-'); + return s[s.length - 1]; +}; + function filterLogs(logs: LogEntry[], platform: Platform) { const output: LogEntry[] = []; const revertedLogs = []; @@ -445,10 +451,13 @@ function capitalizeFirstLetter(string: string) { async function findFirstRelevantTag(baseTag: string, platform: Platform, allTags: string[]) { let baseTagIndex = allTags.indexOf(baseTag); if (baseTagIndex < 0) baseTagIndex = allTags.length; + const baseVersion = versionFromTag(baseTag); for (let i = baseTagIndex - 1; i >= 0; i--) { const tag = allTags[i]; if (platformFromTag(tag) !== platform) continue; + const currentVersion = versionFromTag(tag); + if (compareVersions(baseVersion, currentVersion) <= 0) continue; try { const logs = await gitLog(tag); diff --git a/packages/tools/package.json b/packages/tools/package.json index 108a496e1..0e54f9245 100644 --- a/packages/tools/package.json +++ b/packages/tools/package.json @@ -23,6 +23,7 @@ "@joplin/lib": "~2.11", "@joplin/renderer": "~2.11", "@joplin/utils": "~2.11", + "compare-versions": "6.0.0-rc.1", "dayjs": "1.11.7", "execa": "4.1.0", "fs-extra": "11.1.1", diff --git a/yarn.lock b/yarn.lock index 502a19971..630d85e91 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5151,6 +5151,7 @@ __metadata: "@types/node": 18.15.13 "@types/node-fetch": 2.6.3 "@types/yargs": 17.0.24 + compare-versions: 6.0.0-rc.1 dayjs: 1.11.7 execa: 4.1.0 fs-extra: 11.1.1 @@ -11870,6 +11871,13 @@ __metadata: languageName: node linkType: hard +"compare-versions@npm:6.0.0-rc.1": + version: 6.0.0-rc.1 + resolution: "compare-versions@npm:6.0.0-rc.1" + checksum: ada8d19dab267ef432e7aea91ff7b4422284e3b44245a4d7b4caaf1353d0279e5f17b3767050e06a9cf84670120d19b427b5191b71b7284a125482fcd1eda789 + languageName: node + linkType: hard + "component-emitter@npm:^1.2.1": version: 1.3.0 resolution: "component-emitter@npm:1.3.0"