Permalink
Browse files

getCommit now accepts sha.

  • Loading branch information...
1 parent b030c2f commit 5683d24e30a28ff2a916a5c915af01c9d2311db8 @mbostock committed Feb 28, 2014
Showing with 3 additions and 1 deletion.
  1. +3 −1 index.js
View
@@ -66,7 +66,9 @@ exports.getBranchCommits = function(repository, callback) {
exports.getCommit = function(repository, revision, callback) {
if (arguments.length < 3) callback = revision, revision = null;
- child.exec("git for-each-ref --count 1 --sort=-authordate 'refs/heads/" + (revision ? revision.replace(/'/g, "'\''") : "") + "' --format='%(objectname)\n%(authordate:iso8601)'", {cwd: repository}, function(error, stdout) {
+ child.exec(shaRe.test(revision)
+ ? "git log -1 --date=iso " + revision + " --format='%H\n%ad'"
+ : "git for-each-ref --count 1 --sort=-authordate 'refs/heads/" + (revision ? revision.replace(/'/g, "'\''") : "") + "' --format='%(objectname)\n%(authordate:iso8601)'", {cwd: repository}, function(error, stdout) {
if (error) return callback(error);
var lines = stdout.split("\n"),
sha = lines[0],

0 comments on commit 5683d24

Please sign in to comment.