Skip to content

Add commit-message command #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ git.tag(function (str) {
// => 0.1.0
})

git.message(function (str) {
console.log('message', str)
// => initial commit
})

```

# Methods
Expand Down Expand Up @@ -68,6 +73,9 @@ return the current tag
## .branch(function (branch) { ... })
return the current branch

## .message(function (message) { ... })
return the current commit message

# Install

`npm install git-rev`
Expand Down
8 changes: 8 additions & 0 deletions example/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@ git.log(function (array) {
// '2 days ago',
// 'Thomas Blobaum' ] ]
})

git.message(function (str) {
console.log('message', str)
// => Merge pull request #6 from shtylman/patch-1
//
// fix for launching outside of project dir
//
})
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
var exec = require('child_process').exec

function _command (cmd, cb) {
function _command (cmd, cb, cnl) {
cnl = cnl === undefined ? true : cnl;
exec(cmd, { cwd: __dirname }, function (err, stdout, stderr) {
cb(stdout.split('\n').join(''))
cb(cnl ? stdout.split('\n').join('') : stdout)
})
}

Expand All @@ -25,4 +26,7 @@ module.exports = {
cb(JSON.parse('[' + str + ']'))
})
}
, message : function (cb) {
_command('git log -1 --pretty=%B', cb, false)
}
}