New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

git-common-ancestor

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

git-common-ancestor - npm Package Compare versions

Comparing version 1.1.2 to 2.0.0

6

bin/cli.js

@@ -7,6 +7,6 @@ #!/usr/bin/env node

var minimist = require('minimist');
var gitCommonAncestor = require('../');
const minimist = require('minimist');
const gitCommonAncestor = require('../');
var argv = minimist(process.argv.slice(2));
const argv = minimist(process.argv.slice(2));

@@ -13,0 +13,0 @@ if (!argv.branch) {

'use strict';
var childProcess = require('child_process');
var gitRev = require('git-rev');
const childProcess = require('child_process');
const gitRev = require('git-rev');
function readStreamData(spawnResult) {
return new Promise(function(resolve, reject) {
var input = '';
var error = '';
return new Promise((resolve, reject) => {
let input = '';
let error = '';
spawnResult.stdout.on('data', function(data) {
spawnResult.stdout.on('data', data => {
input += data.toString();
});
spawnResult.stderr.on('data', function(data) {
spawnResult.stderr.on('data', data => {
error += data.toString();
});
spawnResult.on('close', function(code) {
spawnResult.on('close', code => {
if (code !== 0) {

@@ -31,3 +31,3 @@ return reject(new Error(error));

input = input.trim();
var shas = input.split('\n');
const shas = input.split('\n');

@@ -38,3 +38,3 @@ return shas;

function getBranchHistory(branch) {
var result = childProcess.spawn('git', ['rev-list', branch, '--first-parent']);
const result = childProcess.spawn('git', ['rev-list', branch, '--first-parent']);

@@ -46,3 +46,3 @@ return readStreamData(result)

function getShaHistory(sha) {
var result = childProcess.spawn('git', ['rev-list', sha]);
const result = childProcess.spawn('git', ['rev-list', sha]);

@@ -58,4 +58,4 @@ return readStreamData(result)

var smaller = shas1;
var larger = shas2;
let smaller = shas1;
let larger = shas2;

@@ -67,3 +67,3 @@ if (shas2.length < shas1.length) {

for (var i = 0; i < smaller.length; i++) {
for (let i = 0; i < smaller.length; i++) {
if (larger.indexOf(smaller[i]) !== -1) {

@@ -77,18 +77,14 @@ return smaller[i];

var GitCommonAncestor = {
ofShaAndBranch: function(headSha, baseBranch) {
var branchHistory = getBranchHistory(baseBranch);
var shaHistory = getShaHistory(headSha);
const GitCommonAncestor = {
ofShaAndBranch(headSha, baseBranch) {
const branchHistory = getBranchHistory(baseBranch);
const shaHistory = getShaHistory(headSha);
return Promise.all([shaHistory, branchHistory])
.then(function(history) {
return getFirstCommonSha(history[0], history[1]);
});
.then(history => getFirstCommonSha(history[0], history[1]));
},
fromBranch: function(baseBranch) {
fromBranch(baseBranch) {
return new Promise(gitRev.long)
.then((function(sha) {
return this.ofShaAndBranch(sha, baseBranch);
}).bind(this));
.then(sha => this.ofShaAndBranch(sha, baseBranch));
}

@@ -95,0 +91,0 @@ };

{
"name": "git-common-ancestor",
"version": "1.1.2",
"version": "2.0.0",
"description": "Get the common ancestor of a sha and a branch",

@@ -31,14 +31,14 @@ "main": "lib/index.js",

"devDependencies": {
"chai": "3.2.0",
"eslint": "1.3.1",
"jscs": "2.1.1",
"mocha": "2.3.0",
"proxyquire": "1.7.2",
"rewire": "2.3.4",
"rewire-global": "1.0.7",
"sinon": "1.16.1",
"chai": "^3.5.0",
"eslint": "^3.0.0",
"jscs": "^3.0.6",
"mocha": "^2.5.3",
"proxyquire": "^1.7.10",
"rewire": "^2.5.2",
"rewire-global": "^1.0.11",
"sinon": "^1.17.4",
"sinon-as-promised": "4.0.0",
"sinon-sandbox": "1.0.2",
"wealthfront-javascript": "2.3.0"
"wealthfront-javascript": "^3.1.0"
}
}

@@ -7,3 +7,6 @@ # git-common-ancestor

Find the branching point between two points in a git repo. Knowing the branching point is often useful when writing tools that need to look at the changes made on a branch.
For example, if you want to run a linter on all the files that were changed on your branch, you would use this tool to find the point that your branch was created from your main branch and then use `git diff` to find the files changed between those revisions.
## Installation

@@ -10,0 +13,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