98 lines
4.6 KiB
JavaScript
98 lines
4.6 KiB
JavaScript
"use strict";
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.readGitLog = exports.readGitVersion = exports.readSvnVersion = void 0;
|
|
const child_process_1 = __importDefault(require("child_process"));
|
|
const LOG_SPLIT_SEPARATOR = '||||||';
|
|
const exec = (cmd) => {
|
|
const promise = new Promise((resolve) => {
|
|
let result = '';
|
|
const stream = child_process_1.default.spawn(cmd, {});
|
|
stream.on('message', (message, sendHandle) => {
|
|
console.log('stdout: ' + message.toString());
|
|
result !== null && (result += message.toString());
|
|
});
|
|
stream.once("exit", (code, signal) => resolve(result || ""));
|
|
});
|
|
return promise;
|
|
};
|
|
const readSvnVersion = (dir) => {
|
|
const svnInfoString = child_process_1.default.execSync(`cd "${dir}" & svn info`).toString();
|
|
const svnInfo = svnInfoString.split('\n');
|
|
let version;
|
|
for (let item of svnInfo) {
|
|
let info = item.split(': ');
|
|
if (info[0] === 'Revision') {
|
|
version = info[1];
|
|
break;
|
|
}
|
|
}
|
|
return version;
|
|
};
|
|
exports.readSvnVersion = readSvnVersion;
|
|
// export const readSvnLog = (dir: string, startVersion: number): string[] => {
|
|
// }
|
|
const readGitVersion = (dir) => {
|
|
const commit = child_process_1.default.execSync(`cd "${dir}" & git show -s --format=%H`).toString().trim();
|
|
return commit;
|
|
};
|
|
exports.readGitVersion = readGitVersion;
|
|
const readGitLog = (dir, startVersion) => __awaiter(void 0, void 0, void 0, function* () {
|
|
let command = `cd "${dir}" & `;
|
|
command += startVersion ? `git log ${startVersion}.. ` : 'git log ';
|
|
command += `--pretty=format:"%an${LOG_SPLIT_SEPARATOR}%s${LOG_SPLIT_SEPARATOR}%H" --no-merges`;
|
|
const log = child_process_1.default.execSync(command).toString();
|
|
const logArray = log.split('\n');
|
|
const messageArray = [];
|
|
logArray.forEach((element) => {
|
|
if (!element || !element.length)
|
|
return;
|
|
const data = element.split(LOG_SPLIT_SEPARATOR);
|
|
if (!data || data.length !== 3)
|
|
return;
|
|
const [name, title, id] = data;
|
|
if (title === 'commit meta with etc1')
|
|
return;
|
|
if (title.indexOf('from jenkins') >= 0) {
|
|
const jenkinsName = 'Jenkins';
|
|
const resourceLog = child_process_1.default.execSync(`cd "${dir}" & git diff-tree -r --no-commit-id --name-only ${id}`).toString();
|
|
if (resourceLog.indexOf('assets/resources/conf/allConf.json') >= 0)
|
|
messageArray.push({ name: jenkinsName, title: '数据表更新' });
|
|
if (resourceLog.indexOf('assets/resources/conf/allTrack.json') >= 0)
|
|
messageArray.push({ name: jenkinsName, title: 'Track表更新' });
|
|
if (resourceLog.indexOf('assets/resources/conf/path.json') >= 0)
|
|
messageArray.push({ name: jenkinsName, title: 'Path表更新' });
|
|
if (resourceLog.indexOf('assets/resources/audio') >= 0)
|
|
messageArray.push({ name: jenkinsName, title: '音效更新' });
|
|
if (resourceLog.indexOf('assets/res/anim/testure/fish') >= 0 || resourceLog.indexOf('assets/resources/anim/clip/fish') >= 0) {
|
|
const regExp = new RegExp('assets/((resources/anim/clip)|(res/anim/texture))/fish/([a-zA-Z0-9_]+)', 'g');
|
|
const result = [];
|
|
let matchArray;
|
|
while (matchArray = regExp.exec(resourceLog)) {
|
|
let fishName = matchArray[4];
|
|
if (result.indexOf(fishName) >= 0)
|
|
continue;
|
|
result.push(fishName);
|
|
messageArray.push({ name: jenkinsName, title: `${fishName}鱼动画资源更新` });
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
messageArray.push({ name, title });
|
|
}
|
|
});
|
|
return messageArray;
|
|
});
|
|
exports.readGitLog = readGitLog;
|