Skip to content

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

License

Notifications You must be signed in to change notification settings

jantimon/git-rev-sync

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-rev-sync

Build Status

Synchronously get the current git commit hash, tag, count, branch or commit message. 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

You can also run these examples via: npm run examples

Install

npm install git-rev-sync --save

API

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

git.short([filePath]) → <String>

return the result of git rev-parse --short HEAD; optional filePath parameter can be used to run the command against a repo outside the current working directory

git.long([filePath]) → <String>

return the result of git rev-parse HEAD; optional filePath parameter can be used to run the command against a repo outside the current working directory

git.branch([filePath]) → <String>

return the current branch; optional filePath parameter can be used to run the command against a repo outside the current working directory

git.tag([markDirty]) → <String>

return the current tag and mark as dirty if markDirty is truthful; this method will fail if the git command is not found in your PATH

git.isTagDirty() → <Boolean>

returns true if the current tag is dirty.

git.message() → <String>

return the current commit message; this method will fail if the git command is not found in your PATH

git.count() → <Number>

return the count of commits across all branches; this method will fail if the git command is not found in your PATH

License

MIT

Donations

We're all in this together

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%