Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions lib/git-fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down