git-rev-sync
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/git-rev-sync package

3.0.2 • Public • Published

git-rev-sync Build Status

Synchronously get the current git commit hash, tag, count, branch or commit message. Forked from git-rev. Supports Node 4+.

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], [length]) → <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
  • optional length parameter can be used to set the desired hash length (defaults to 7)

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.count() → <Number>

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

git.date() → <Date>

returns the date of the current commit; this method will fail if the git command is not found in PATH

git.hasUnstagedChanges() → <Boolean>

returns true if there are unstaged changes; this method will fail if the git command is not found in PATH

git.isDirty() → <Boolean>

returns true if there are uncommitted changes; this method will fail if the git command is not found in PATH

git.isTagDirty() → <Boolean>

returns true if the current tag is dirty; this method will fail if the git command is not found in PATH

git.message() → <String>

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

git.remoteUrl() → <String>

return the current remote URL; this method will fail if the git command is not found in PATH

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 PATH

License

MIT

Donations

We're all in this together

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
3.0.2121,123latest

Version History

VersionDownloads (Last 7 Days)Published
3.0.2121,123
3.0.120,730
3.0.00
2.1.07,029
2.0.03,448
1.12.010,217
1.11.27
1.11.11
1.11.01
1.10.0359
1.9.1181
1.9.00
1.8.0533
1.7.115
1.7.00
1.6.04
1.5.11
1.5.0105
1.4.054
1.3.01
1.1.00
1.0.00
0.1.41
0.1.31
0.1.20
0.1.11
0.1.00

Package Sidebar

Install

npm i git-rev-sync

Weekly Downloads

163,812

Version

3.0.2

License

MIT

Unpacked Size

13.3 kB

Total Files

9

Last publish

Collaborators

  • kurttheviking