From c760bdce4baa372f42c868be4c992b2b35da2698 Mon Sep 17 00:00:00 2001 From: payload Date: Sat, 21 May 2011 14:32:29 +0200 Subject: [PATCH] Final commit, ready for tagging --- lib/git/commit.js | 37 +++++++++++++++++++++++++++++-------- lib/git/git.js | 3 ++- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/lib/git/commit.js b/lib/git/commit.js index aaf6f82..298ef63 100644 --- a/lib/git/commit.js +++ b/lib/git/commit.js @@ -120,7 +120,11 @@ var actor = function(line) { Commit.list_from_string = function(repo, text) { // Split up the result var lines = text.split("\n"); - var linesshift = function() { return lines.shift(); }; + var linesshift = function() { + var l = lines.shift(); + // console.log(l); + return l; + }; var commits = []; // Parse all commit messages while(lines.length > 0) { @@ -152,17 +156,34 @@ Commit.list_from_string = function(repo, text) { linesshift(); // Parse --raw lines - var filechanges = [] + var filechanges = {}; + var fcre = /:(\d+) (\d+) ([a-z0-9]+) ([a-z0-9]+) (\S+)\s+(.+)/; + var numre = /(\S+)\s+(\S+)\s+(.+)/; + var line; + var matched; while (lines.length > 0) { - var re = /:(\d+) (\d+) ([a-z0-9]+) ([a-z0-9]+) (\S+)\s+(.+)/; - var rawline = linesshift().match(re); - if (!rawline) break; - var filechange = {}; + line = linesshift(); + matched = line.match(fcre); + if (!matched) break; + var o = {}; var xs = ['a_mode', 'b_mode', 'a_blob', 'b_blob', 'what', 'path']; for(var i = 0; i < xs.length; i++) { - filechange[xs[i]] = rawline[i+1]; + o[xs[i]] = matched[i+1]; } - filechanges.push(filechange); + filechanges[o.path] = o; + } + while (line) { + matched = line.match(numre); + if (!matched) break; + var o = {}; + var xs = ['plus', 'minus', 'path']; + for(var i = 0; i < xs.length; i++) { + o[xs[i]] = matched[i+1]; + } + filechanges[o.path].plus = o.plus; + filechanges[o.path].minus = o.minus; + if (lines.length == 0) break; + line = linesshift(); } // Move and point to next message diff --git a/lib/git/git.js b/lib/git/git.js index 8b4aca4..a7d6a4b 100644 --- a/lib/git/git.js +++ b/lib/git/git.js @@ -228,6 +228,7 @@ Git.prototype.call_git = function(prefix, command, postfix, options, args, callb var execute_git_call = function(call_string, options, callback) { // Execute the git command + options.maxBuffer = 1024 * 1024; exec(call_string, options, function (error, stdout, stderr) { if (error != null) { @@ -605,7 +606,7 @@ Git.prototype.fs_write = function(file, content, callback) { // Log function, returns the number of logs Git.prototype.log = function(commit, path, options, callback) { - args = ['--raw', '--no-abbrev']; + args = ['--raw', '--no-abbrev', '--numstat']; if (path) { args.push('--'); args.push(path);