UNPKG

semantic-release-gerrit

Version:

Gerrit release notes generator plugin for semantic-release

107 lines (106 loc) 3.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _a; var compareFunc = require("compare-func"); exports.writerOptionsConfig = { transform: function (commit, context) { var discard = true; var issues = []; commit.notes.forEach(function (note) { note.title = "BREAKING CHANGES"; discard = false; }); if (commit.type === "feat") { commit.type = "Features"; } else if (commit.type === "fix") { commit.type = "Bug Fixes"; } else if (commit.type === "perf") { commit.type = "Performance Improvements"; } else if (commit.type === "revert") { commit.type = "Reverts"; } else if (discard) { return; } else if (commit.type === "docs") { commit.type = "Documentation"; } else if (commit.type === "style") { commit.type = "Styles"; } else if (commit.type === "refactor") { commit.type = "Code Refactoring"; } else if (commit.type === "test") { commit.type = "Tests"; } else if (commit.type === "build") { commit.type = "Build System"; } else if (commit.type === "ci") { commit.type = "Continuous Integration"; } if (commit.scope === "*") { commit.scope = ""; } if (typeof commit.hash === "string") { commit.hash = commit.hash.substring(0, 7); } if (typeof commit.subject === "string") { var url_1 = context.issues; if (url_1) { commit.subject = commit.subject.replace(/#([0-9]+)/g, function (_, issue) { issues.push(issue); return "[#" + issue + "](" + url_1 + "/" + 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)"); } } // remove references that already appear in the subject commit.references = commit.references.filter(function (reference) { return issues.indexOf(reference.issue) === -1; }); return commit; }, groupBy: "type", commitGroupsSort: "title", commitsSort: ["scope", "subject"], noteGroupsSort: "title", notesSort: compareFunc }; exports.parserOptions = { headerPattern: /^(\w*)(?:\((.*)\))?: (.*)$/, headerCorrespondence: [ "type", "scope", "subject" ], noteKeywords: ["BREAKING CHANGE"], revertPattern: /^revert:\s([\s\S]*?)\s*This reverts commit (\w*)\./, revertCorrespondence: ["header", "hash"] }; exports.GERRIT_HOST_CONFIG = { commit: '#/c', issuePrefixes: ['#'], referenceActions: [ "close", "closes", "closed", "closing", "fix", "fixes", "fixed", "fixing", "resolve", "resolves", "resolved", "resolving", ] }; (_a = exports.GERRIT_HOST_CONFIG.referenceActions).push.apply(_a, exports.GERRIT_HOST_CONFIG.referenceActions.map(function (action) { return action + ":"; }));