Synchronously get the current git commit hash, tag, or branch
Installations
npm install git-rev-sync
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
14.7.0
NPM Version
6.14.7
Score
92.9
Supply Chain
95.6
Quality
74.9
Maintenance
100
Vulnerability
98.2
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
kurttheviking
Download Statistics
Total Downloads
141,828,504
Last Day
52,413
Last Week
219,541
Last Month
958,748
Last Year
16,634,438
GitHub Statistics
171 Stars
165 Commits
59 Forks
4 Watching
3 Branches
2 Contributors
Bundle Size
74.42 kB
Minified
23.82 kB
Minified + Gzipped
Package Meta Information
Latest Version
3.0.2
Package Id
git-rev-sync@3.0.2
Unpacked Size
13.01 kB
Size
4.46 kB
File Count
9
NPM Version
6.14.7
Node Version
14.7.0
Total Downloads
Cumulative downloads
Total Downloads
141,828,504
Last day
7.8%
52,413
Compared to previous day
Last week
-7.7%
219,541
Compared to previous week
Last month
-3.9%
958,748
Compared to previous month
Last year
-30%
16,634,438
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
3
git-rev-sync
Synchronously get the current git commit hash, tag, count, branch or commit message. Forked from git-rev. Supports Node 4+.
Example
1var git = require('git-rev-sync'); 2 3console.log(git.short()); 4// 75bf4ee 5 6console.log(git.long()); 7// 75bf4eea9aa1a7fd6505d0d0aa43105feafa92ef 8 9console.log(git.branch()); 10// master
You can also run these examples via: npm run examples
Install
npm install git-rev-sync --save
API
1var 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 to7
)
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
Donations
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
1 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
Reason
Found 10/29 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 11 are checked with a SAST tool
Score
3.3
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to git-rev-sync
@types/git-rev-sync
TypeScript definitions for git-rev-sync
@destinationstransfers/git-rev-sync
Get current git commit hash
@adam-lynch/git-rev-sync
Synchronously get the current git commit hash, tag, or branch
tiny-git-rev-sync
A tiny fork of https://github.com/kurttheviking/git-rev-sync-js written in typescript