Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

git-repo-info

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

git-repo-info - npm Package Compare versions

Comparing version 1.4.1 to 2.0.0

46

index.js

@@ -152,2 +152,36 @@ 'use strict';

var LAST_TAG_CACHE = {};
function findLastTagCached(gitPath, sha, commitsSinceLastTag) {
if(!LAST_TAG_CACHE[gitPath]) {
LAST_TAG_CACHE[gitPath] = {};
}
if(!LAST_TAG_CACHE[gitPath][sha]) {
LAST_TAG_CACHE[gitPath][sha] = findLastTag(gitPath, sha, commitsSinceLastTag);
}
return LAST_TAG_CACHE[gitPath][sha];
}
function findLastTag(gitPath, sha, commitsSinceLastTag) {
commitsSinceLastTag = commitsSinceLastTag || 0;
var tag = findTag(gitPath, sha);
if(!tag) {
var commitData = getCommitData(gitPath, sha);
if(!commitData) {
return { tag: null, commitsSinceLastTag: Infinity };
}
return commitData.parents
.map(parent => findLastTag(gitPath, parent, commitsSinceLastTag + 1))
.reduce((a,b) => {
return a.commitsSinceLastTag < b.commitsSinceLastTag ? a : b;
}, { commitsSinceLastTag: Infinity });
}
return {
tag: tag,
commitsSinceLastTag: commitsSinceLastTag
};
}
function findUnpackedTags(gitPath, sha) {

@@ -183,3 +217,5 @@ var unpackedTags = [];

commitMessage: null,
root: null
root: null,
lastTag: null,
commitsSinceLastTag: 0,
};

@@ -233,2 +269,6 @@

}
var lastTagInfo = findLastTagCached(gitPathInfo.commonGitDir, result.sha);
result.lastTag = lastTagInfo.tag;
result.commitsSinceLastTag = lastTagInfo.commitsSinceLastTag;
}

@@ -269,3 +309,2 @@ } catch (e) {

case 'tree':
case 'parent':
//ignore these for now

@@ -282,2 +321,5 @@ break;

break;
case 'parent':
data.parents = section.split('\n').map(p => p.split(' ')[1]);
break;
default:

@@ -284,0 +326,0 @@ //should just be the commit message left

5

package.json
{
"name": "git-repo-info",
"version": "1.4.1",
"version": "2.0.0",
"description": "Retrieve current sha and branch name from a git repo.",

@@ -30,3 +30,6 @@ "main": "index.js",

"mocha-jshint": "^1.1.0"
},
"engines": {
"node": ">= 4.0"
}
}

@@ -12,11 +12,15 @@ ## git-repo-info

info.branch //=> will be the current branch
info.sha //=> will be the current sha
info.abbreviatedSha //=> will be the first 10 chars of the current sha
info.tag //=> will be the tag for the current sha (or `null` if no tag exists)
info.committer //=> will be the committer for the current sha
info.committerDate //=> will be the commit date for the current sha
info.author //=> will be the author for the current sha
info.authorDate //=> will be the authored date for the current sha
info.commitMessage //=> will be the commit message for the current sha
info.branch // current branch
info.sha // current sha
info.abbreviatedSha // first 10 chars of the current sha
info.tag // tag for the current sha (or `null` if no tag exists)
info.lastTag // tag for the closest tagged ancestor
// (or `null` if no ancestor is tagged)
info.commitsSinceLastTag // number of commits since the closest tagged ancestor
// (`0` if this commit is tagged, or `Infinity` if no ancestor is tagged)
info.committer           // committer for the current sha
info.committerDate // commit date for the current sha
info.author // author for the current sha
info.authorDate // authored date for the current sha
info.commitMessage // commit message for the current sha
```

@@ -23,0 +27,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc