Permalink
Browse files
Allow getCommit to be called without a revision.
In this case, it returns the most recent commit for any branch.
- Loading branch information...
Showing
with
4 additions
and
3 deletions.
-
+3
−2
index.js
-
+1
−1
package.json
|
@@ -42,12 +42,13 @@ exports.getSha = function(repository, revision, callback) { |
|
|
};
|
|
|
|
|
|
exports.getCommit = function(repository, revision, callback) {
|
|
|
- child.exec("git log -1 --format=\"format:%H%n%ad\" '" + revision.replace(/'/g, "'\''") + "'", {cwd: repository}, function(error, stdout) {
|
|
|
+ if (arguments.length < 3) callback = revision, revision = null;
|
|
|
+ child.exec("git for-each-ref --count 1 --sort=-committerdate '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");
|
|
|
callback(null, {
|
|
|
sha: lines[0],
|
|
|
- date: new Date(Date.parse(lines[1]))
|
|
|
+ date: new Date(lines[1])
|
|
|
});
|
|
|
});
|
|
|
};
|
|
|
|
|
@@ -1,6 +1,6 @@ |
|
|
{
|
|
|
"name": "git-static",
|
|
|
- "version": "0.0.11",
|
|
|
+ "version": "0.0.12",
|
|
|
"author": {
|
|
|
"name": "Mike Bostock",
|
|
|
"url": "http://bost.ocks.org/mike"
|
|
|
0 comments on commit
9e837a8