diff --git a/lib/git-fs.js b/lib/git-fs.js index a8be53c..553a4dc 100755 --- a/lib/git-fs.js +++ b/lib/git-fs.js @@ -213,7 +213,38 @@ function gitExec(commands, encoding, callback) { child.stdin.end(); } +var parseSummaryLogEntry = function(entry) { + var id = entry.match(/^commit ([a-f0-9]{40})/)[1]; + var commit = { + id: id, + message: entry.match(/\n\n([\s\S]*)/)[1].trim() + } + + entry.match(/^[A-Z][a-z]*:.*$/gm).forEach(function (line) { + var matches = line.match(/^([A-Za-z]+):\s*(.*)$/); + commit[matches[1].toLowerCase()] = matches[2]; + }); + + return commit; +}; + +Git.logBetween = function(from, to, callback) { + var commands; + var args = ["log", "-z", from + ".." + to] + + gitExec(args, 'utf8', function(err, text) { + if (err) { callback(err); return; } + if (text.length === 0) { callback(null, []); return; } + + var log = []; + text.split("\0").forEach(function (entry) { + log.push(parseSummaryLogEntry(entry)); + }); + + callback(null, log); + }); +}; var logFile = safe(function logFile(version, path, callback) { // Get the data from a git subprocess at the given sha hash.