1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Tools: Allow creating simplified changelog for app stores

This commit is contained in:
Laurent Cozic 2020-01-25 10:42:36 +00:00
parent 9dda65de20
commit 101935e594

View File

@ -80,7 +80,9 @@ function filterLogs(logs, platform) {
return output; return output;
} }
function formatCommitMessage(msg, author) { function formatCommitMessage(msg, author, options) {
options = Object.assign({}, { publishFormat: 'full' }, options);
let output = ''; let output = '';
const splitted = msg.split(':'); const splitted = msg.split(':');
@ -171,33 +173,40 @@ function formatCommitMessage(msg, author) {
messagePieces.push(`${capitalizeFirstLetter(commitMessage.message)}`); messagePieces.push(`${capitalizeFirstLetter(commitMessage.message)}`);
output = messagePieces.join(': '); output = messagePieces.join(': ');
if (commitMessage.issueNumber) {
const formattedIssueNum = `(#${commitMessage.issueNumber})`;
if (output.indexOf(formattedIssueNum) < 0) output += ` ${formattedIssueNum}`;
}
let authorMd = null; if (options.publishFormat === 'full') {
if (author && (author.login || author.name) && author.login !== 'laurent22') { if (commitMessage.issueNumber) {
if (author.login) { const formattedIssueNum = `(#${commitMessage.issueNumber})`;
const escapedLogin = author.login.replace(/\]/g, ''); if (output.indexOf(formattedIssueNum) < 0) output += ` ${formattedIssueNum}`;
authorMd = `[@${escapedLogin}](https://github.com/${encodeURI(author.login)})`; }
} else {
authorMd = `${author.name}`; let authorMd = null;
if (author && (author.login || author.name) && author.login !== 'laurent22') {
if (author.login) {
const escapedLogin = author.login.replace(/\]/g, '');
authorMd = `[@${escapedLogin}](https://github.com/${encodeURI(author.login)})`;
} else {
authorMd = `${author.name}`;
}
}
if (authorMd) {
output = output.replace(/\((#[0-9]+)\)$/, `($1 by ${authorMd})`);
} }
} }
if (authorMd) { if (options.publishFormat !== 'full') {
output = output.replace(/\((#[0-9]+)\)$/, `($1 by ${authorMd})`); output = output.replace(/\((#[0-9]+)\)$/, '');
} }
return output; return output;
} }
function createChangeLog(logs) { function createChangeLog(logs, options) {
const output = []; const output = [];
for (const log of logs) { for (const log of logs) {
output.push(formatCommitMessage(log.message, log.author)); output.push(formatCommitMessage(log.message, log.author, options));
} }
return output; return output;
@ -251,7 +260,9 @@ async function main() {
const filteredLogs = filterLogs(logsSinceTags, platform); const filteredLogs = filterLogs(logsSinceTags, platform);
let changelog = createChangeLog(filteredLogs); let publishFormat = 'full';
if (['android', 'ios'].indexOf(platform) >= 0) publishFormat = 'simple';
let changelog = createChangeLog(filteredLogs, { publishFormat: publishFormat });
const changelogFixes = []; const changelogFixes = [];
const changelogImproves = []; const changelogImproves = [];