Permalink
Browse files

add log command, reorganize a bit

  • Loading branch information...
1 parent 2765664 commit f9046ee7638d0814a514f11dc714947757e9e6cd @tblobaum committed Aug 9, 2012
Showing with 20 additions and 17 deletions.
  1. +20 −17 index.js
View
@@ -2,24 +2,27 @@ var exec = require('child_process').exec
function _command (cmd, cb) {
exec(cmd, function (err, stdout, stderr) {
- cb(stdout.split('\n')[0])
+ cb(stdout.split('\n').join(''))
})
}
-function short (cb) {
- _command('git rev-parse --short HEAD', cb)
+module.exports = {
+ short : function (cb) {
+ _command('git rev-parse --short HEAD', cb)
+ }
+ , long : function (cb) {
+ _command('git rev-parse HEAD', cb)
+ }
+ , branch : function (cb) {
+ _command('git rev-parse --abbrev-ref HEAD', cb)
+ }
+ , tag : function (cb) {
+ _command('git describe --always --tag', cb)
+ }
+ , log : function (cb) {
+ _command('git log --no-color --pretty=format:\'[ "%H", "%s", "%cr", "%an" ],\' --abbrev-commit', function (str) {
+ str = str.substr(0, str.length-1)
+ cb(JSON.parse('[' + str + ']'))
+ })
+ }
}
-
-function long (cb) {
- _command('git rev-parse HEAD', cb)
-}
-
-function branch (cb) {
- _command('git rev-parse --abbrev-ref HEAD', cb)
-}
-
-function tag (cb) {
- _command('git describe --always --tag', cb)
-}
-
-module.exports = { short : short, long : long, branch : branch, tag : tag }

0 comments on commit f9046ee

Please sign in to comment.