Socket
Socket
Sign inDemoInstall

@lerna/git-utils

Package Overview
Dependencies
Maintainers
4
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lerna/git-utils - npm Package Compare versions

Comparing version 3.0.0-beta.0 to 3.0.0-beta.3

CHANGELOG.md

51

index.js

@@ -137,11 +137,13 @@ "use strict";

function diffSinceIn(committish, location, opts) {
const args = ["diff", "--name-only", committish];
const formattedLocation = slash(path.relative(opts.cwd, location));
if (formattedLocation) {
// avoid same-directory path.relative() === ""
args.push("--", formattedLocation);
}
log.silly("diffSinceIn", committish, formattedLocation);
const diff = ChildProcessUtilities.execSync(
"git",
["diff", "--name-only", committish, "--", formattedLocation],
opts
);
const diff = ChildProcessUtilities.execSync("git", args, opts);
log.silly("diff", diff);

@@ -213,2 +215,38 @@

function fetchGitRemote(opts) {
log.silly("fetchGitRemote");
ChildProcessUtilities.execSync("git", ["remote", "update"], opts);
}
function isBehindUpstream(gitRemote, opts) {
log.silly("isBehindUpstream");
exports.fetchGitRemote(opts);
const status = exports.aheadBehindCount(gitRemote, opts);
const behind = status.behind >= 1;
log.verbose("isBehindUpstream", behind);
return behind;
}
function aheadBehindCount(gitRemote, opts) {
const branchName = exports.getCurrentBranch(opts);
const branchComparator = `${gitRemote}/${branchName}...${branchName}`;
const rawAheadBehind = ChildProcessUtilities.execSync(
"git",
["rev-list", "--left-right", "--count", branchComparator],
opts
);
const aheadBehind = rawAheadBehind.split("\t");
const behind = parseInt(aheadBehind[0], 10);
const ahead = parseInt(aheadBehind[1], 10);
log.silly(
"aheadBehindCount",
`behind ${gitRemote}/${branchName} by ${behind} commits; ${branchName} is ahead by ${ahead} commits`
);
return { ahead, behind };
}
exports.isDetachedHead = isDetachedHead;

@@ -234,1 +272,4 @@ exports.isInitialized = isInitialized;

exports.hasCommit = hasCommit;
exports.fetchGitRemote = fetchGitRemote;
exports.isBehindUpstream = isBehindUpstream;
exports.aheadBehindCount = aheadBehindCount;

4

package.json
{
"name": "@lerna/git-utils",
"version": "3.0.0-beta.0",
"version": "3.0.0-beta.3",
"description": "TODO",

@@ -38,3 +38,3 @@ "keywords": [

},
"gitHead": "349b9c765bcbf38988d1fcd48313422417a04c8f"
"gitHead": "1ee15326adf778c32e4b136bbfb27e1c899716a1"
}
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