t-comm
Version:
专业、稳定、纯粹的工具库
55 lines (50 loc) • 1.72 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var git_gitLink = require('../git/git-link.js');
require('../slash/slash.js');
function genRobotMsg(_ref) {
var errorMap = _ref.errorMap,
mrId = _ref.mrId,
mrUrl = _ref.mrUrl,
repoConfig = _ref.repoConfig,
total = _ref.total;
var domain = repoConfig.domain,
repo = repoConfig.repo,
branch = repoConfig.branch;
var detailList = Object.keys(errorMap).map(function (key) {
var _errorMap$key = errorMap[key],
filePath = _errorMap$key.filePath,
line = _errorMap$key.line,
number = _errorMap$key.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() {
var repo = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
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;