diff --git a/lib/commit-groups-compare.js b/lib/commit-groups-compare.js index f729621..a3d60d2 100644 --- a/lib/commit-groups-compare.js +++ b/lib/commit-groups-compare.js @@ -16,20 +16,26 @@ module.exports = (group1, group2) => { if (idx1 !== -1 && idx2 === -1) { return -1; } + if (idx1 === -1 && idx2 !== -1) { return 1; } + if (idx1 < idx2) { return -1; } + if (idx1 > idx2) { return 1; } + if (group1.title < group2.title) { return -1; } + if (group1.title > group2.title) { return 1; } + return 0; }; diff --git a/lib/commit-transform.js b/lib/commit-transform.js index 1e7dacb..d64ff10 100644 --- a/lib/commit-transform.js +++ b/lib/commit-transform.js @@ -33,6 +33,7 @@ module.exports = (commit, context) => { if (typeof commit.hash === 'string') { commit.hash = commit.hash.substring(0, COMMIT_HASH_LENGTH); } + const references = []; if (typeof commit.subject === 'string') { @@ -46,19 +47,23 @@ module.exports = (commit, context) => { return `[#${issue}](${url}${issue})`; }); } + if (context.host) { // User URLs. commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9]){0,38})/g, `[@$1](${context.host}/$1)`); } } + if (commit.references) { // Remove references that already appear in the subject commit.references = commit.references.filter(reference => { if (references.indexOf(reference.issue) === -1) { return true; } + return false; }); } + return commit; }; diff --git a/package.json b/package.json index 90ddb39..1cd660b 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "semantic-release": "^15.0.0", "stringz": "^1.0.0", "tempy": "^0.2.0", - "xo": "^0.23.0" + "xo": "^0.24.0" }, "engines": { "node": ">=6"