Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add log command, reorganize a bit

  • Loading branch information...
commit f9046ee7638d0814a514f11dc714947757e9e6cd 1 parent 2765664
@tblobaum authored
Showing with 20 additions and 17 deletions.
  1. +20 −17 index.js
View
37 index.js
@@ -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 }
Please sign in to comment.
Something went wrong with that request. Please try again.