-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget_git_log.js
35 lines (27 loc) · 947 Bytes
/
get_git_log.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use strict';
exports.getGitLog = getGitLog;
function getGitLog(gitPath, callback)
{
const exec = require('child_process').exec;
let options = {};
options.maxBuffer = 20000 * 1024;//默认为200*1024,但是默认值太小,导致有时候输出太多出问题
// git --git-dir="XXX/XXX" --no-pager log --reflog --pretty=format:"%ad||%an" > aaa.txt
let cmdStr = "git --git-dir=\"" + gitPath + "\" --no-pager log --reflog --pretty=format:\"['%ad','%an'],\"";
let mProcess = exec(cmdStr, options);
let text = "";
mProcess.stdout.on('data', function (data)
{
// console.log('log: ' + data, 1);
text += data;
});
mProcess.stderr.on('data', function (data)
{
console.log('error: ' + data, 1);
});
mProcess.on('exit', function(code){
if (callback)
{
callback(text);
}
});
}