UNPKG

git-release-manager

Version:

A tool to generate release notes from git commit history

50 lines 2.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getContributors = getContributors; function getContributors(commits, config) { const contributors = {}; commits.forEach(commit => { const allContributors = [commit.author, ...(commit.mentions || [])]; allContributors.forEach(contributor => { var _a; const key = contributor.email; if (!contributors[key]) { contributors[key] = { ...contributor, groups: [], files: [], commits: [], }; } const normalizePath = (path) => path.replace(/\\/g, '/'); commit.files.forEach(file => { var _a; const normalizedFile = normalizePath(file); Object.entries(config.fileGroups).forEach(([group, paths]) => { var _a; if (paths.some((path) => normalizedFile.startsWith(normalizePath(path)))) { let groupObj = (_a = contributors[key].groups) === null || _a === void 0 ? void 0 : _a.find((g) => g.title === group); if (!groupObj) { groupObj = { title: group, files: [], commits: [] }; contributors[key].groups.push(groupObj); } if (!groupObj.files.includes(normalizedFile)) { groupObj.files.push(normalizedFile); } if (!groupObj.commits.includes(commit)) { groupObj.commits.push(commit); } } }); if (!((_a = contributors[key].files) === null || _a === void 0 ? void 0 : _a.includes(normalizedFile))) { contributors[key].files.push(normalizedFile); } }); if (!((_a = contributors[key].commits) === null || _a === void 0 ? void 0 : _a.includes(commit))) { contributors[key].commits.push(commit); } }); }); return Object.values(contributors); } //# sourceMappingURL=contributors.js.map