git-rev-sync
    Overview
    Documentation
    Tutorials
    Chat
    Insights
    Code
    Dependencies
    Contributors
    Jobs

git-rev-sync

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

1.12.0  •  Updated 2 years ago  •  by Kurt Ericson  •  MIT License

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], [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.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

Popularity

Maintenance

Development

Last ver 2 years ago
Created 5 years ago
Last commit 4 months ago
13 days between commits

Technology

Node version: 6.12.3
13.4K unpacked

Compliance

MIT License
OSI Approved
0 vulnerabilities

Contributors

26 contributors
kurttheviking
77 commits
Kurt Ericson
Maintainer, 44 commits, 24 merges
Works at google
Thomas Blobaum
10 commits
Henrik Raitasola
Maintainer, 3 commits, 2 PRs
Eugene Zolenko
3 commits
Works at SMART Technologies
jden
2 commits, 1 PRs
Openbase helps developers choose among and use millions of open-source packages, so they can build amazing products faster.
FacebookTwitterLinkedIn
© 2020 Devstore, Inc.