Skip to content

Synchronously get the current git commit hash, tag, or branch

License

Notifications You must be signed in to change notification settings

kurttheviking/git-rev-sync-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-rev-sync

Synchronously get the current git commit hash, tag, or branch. Forked from git-rev.

Example

var git = require('git-rev-sync');

console.log(git.short());
// 75bf4ee

console.log(git.long());
// 75bf4eea9aa1a7fd6505d0d0aa43105feafa92ef

console.log(git.branch());
// master

console.log(git.tag());
// 0.1.0

console.log(git.log());
// [
//   [
//     '75bf4eea9aa1a7fd6505d0d0aa43105feafa92ef',
//     'update pjson to include sync exec',
//     '17 minutes ago',
//     'kurttheviking'
//   ],
//   [
//     '143120ac3ecc07aeae1462b372bb2033aa20c3ee',
//     'Merge pull request #6 from shtylman/patch-1',
//     '1 year, 2 months ago',
//     'Thomas Blobaum'
//   ],
//   ...
// ]

You can also run these examples via: npm run examples

Install

npm install git-rev-sync --save

Methods

var git = require('git-rev-sync');

.log() => <Array: <Tuple>>

return the git log of process.cwd() as an array; each array contains the long commit hash, commit message, fuzzy commit time, and user

.short() => <String>

return the result of git rev-parse --short HEAD

.long() => <String>

return the result of git rev-parse HEAD

.tag() => <String>

return the current tag

.branch() => <String>

return the current branch

Warning

Not tested outside of a *nix system. See the execSync module notes on this topic.

License

MIT

About

Synchronously get the current git commit hash, tag, or branch

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%