From 4ceeb304f12be913288a15d4e7bdd5784c68e297 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Fri, 24 Nov 2023 18:44:54 +0800 Subject: [PATCH] Add a script to prepare a changelog --- extra/reformat-changelog.js | 44 +++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 extra/reformat-changelog.js diff --git a/extra/reformat-changelog.js b/extra/reformat-changelog.js new file mode 100644 index 000000000..80a1b725a --- /dev/null +++ b/extra/reformat-changelog.js @@ -0,0 +1,44 @@ +// Generate on GitHub +const input = ` +* Add Korean translation by @Alanimdeo in https://github.com/louislam/dockge/pull/86 +`; + +const template = ` +### 🆕 New Features + +### 💇‍♀️ Improvements + +### 🐞 Bug Fixes + +### ⬆️ Security Fixes + +### 🦎 Translation Contributions + +### Others +- Other small changes, code refactoring and comment/doc updates in this repo: +`; + +const lines = input.split("\n").filter((line) => line.trim() !== ""); + +for (const line of lines) { + // Split the last " by " + const usernamePullRequesURL = line.split(" by ").pop(); + + if (!usernamePullRequesURL) { + console.log("Unable to parse", line); + continue; + } + + const [ username, pullRequestURL ] = usernamePullRequesURL.split(" in "); + const pullRequestID = "#" + pullRequestURL.split("/").pop(); + let message = line.split(" by ").shift(); + + if (!message) { + console.log("Unable to parse", line); + continue; + } + + message = message.split("* ").pop(); + console.log("-", pullRequestID, message, `(Thanks ${username})`); +} +console.log(template);