UNPKG

t-comm

Version:

专业、稳定、纯粹的工具库

57 lines (52 loc) 1.63 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var git_gitLink = require('../git/git-link.js'); require('../slash/slash.js'); function genRobotMsg(_a) { var errorMap = _a.errorMap, mrId = _a.mrId, mrUrl = _a.mrUrl, repoConfig = _a.repoConfig, total = _a.total; var domain = repoConfig.domain, repo = repoConfig.repo, branch = repoConfig.branch; var detailList = Object.keys(errorMap).map(function (key) { var _a = errorMap[key], filePath = _a.filePath, line = _a.line, number = _a.number; var link = git_gitLink.getGitCodeLink({ domain: domain, repo: repo, branch: branch, localFile: filePath, line: "".concat(line) }); return "[".concat(key, "*").concat(number, "](").concat(link, ")"); }); var detail = detailList.join(','); if (detailList.length > 10) { detail += ' ...'; } var mrLink = git_gitLink.getGitMRLink({ domain: domain, repo: repo, id: "".concat(mrId) }); if (mrUrl) { mrLink = mrUrl; } var getRepoName = function getRepoName(repo) { if (repo === void 0) { repo = ''; } var list = git_gitLink.rmFirstAndLastSlash(repo).split('/'); return list[list.length - 1]; }; var repoName = getRepoName(repo); var linkPostfix = mrId ? "#".concat(mrId) : ''; var content = ">\u3010Eslint\u9519\u8BEF\u3011[".concat(repoName).concat(linkPostfix, "](").concat(mrLink, ") ").concat(mrId ? 'MR' : '', "\u5B58\u5728").concat(total, "\u6761ESlint\u9519\u8BEF\uFF1A").concat(detail); return content; } exports.genRobotMsg = genRobotMsg;