Socket
Socket
Sign inDemoInstall

isomorphic-git

Package Overview
Dependencies
Maintainers
1
Versions
408
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

isomorphic-git - npm Package Compare versions

Comparing version 0.0.19 to 0.0.20

161

dist/for-browserify/managers.js

@@ -18,2 +18,3 @@ 'use strict';

var AsyncLock = _interopDefault(require('async-lock'));
var ignore = _interopDefault(require('ignore'));
var buffer = require('buffer');

@@ -336,2 +337,161 @@ var pako = _interopDefault(require('pako'));

// @flow
// I'm putting this in a Manager because I reckon it could benefit
// from a LOT of cacheing.
var GitIgnoreManager = function () {
function GitIgnoreManager() {
_classCallCheck(this, GitIgnoreManager);
}
_createClass(GitIgnoreManager, null, [{
key: 'isIgnored',
value: function () {
var _ref2 = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(_ref) {
var gitdir = _ref.gitdir,
workdir = _ref.workdir,
pathname = _ref.pathname;
var pairs, pieces, i, dir, file, ignoredStatus, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, p, _file, ign, parentdir;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
pairs = [{
gitignore: path.join(workdir, '.gitignore'),
pathname: pathname
}];
pieces = pathname.split('/');
for (i = 1; i < pieces.length; i++) {
dir = pieces.slice(0, i).join('/');
file = pieces.slice(i).join('/');
pairs.push({
gitignore: path.join(workdir, dir, '.gitignore'),
pathname: file
});
}
ignoredStatus = false;
_iteratorNormalCompletion = true;
_didIteratorError = false;
_iteratorError = undefined;
_context.prev = 7;
_iterator = _getIterator(pairs);
case 9:
if (_iteratorNormalCompletion = (_step = _iterator.next()).done) {
_context.next = 30;
break;
}
p = _step.value;
_file = void 0;
_context.prev = 12;
_context.next = 15;
return utils_js.read(p.gitignore, 'utf8');
case 15:
_file = _context.sent;
_context.next = 22;
break;
case 18:
_context.prev = 18;
_context.t0 = _context['catch'](12);
if (!(_context.t0.code === 'NOENT')) {
_context.next = 22;
break;
}
return _context.abrupt('continue', 27);
case 22:
ign = ignore().add(_file);
// If the parent directory is excluded, we are done.
// "It is not possible to re-include a file if a parent directory of that file is excluded. Git doesn’t list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined."
// source: https://git-scm.com/docs/gitignore
parentdir = path.dirname(p.pathname);
if (!ign.ignores(parentdir)) {
_context.next = 26;
break;
}
return _context.abrupt('return', true);
case 26:
// If the file is currently ignored, test for UNignoring.
if (ignoredStatus) {
if (!ignore().add('**\n' + _file).ignores(p.pathname)) {
ignoredStatus = false;
}
} else {
ignoredStatus = ign.ignores(p.pathname);
}
case 27:
_iteratorNormalCompletion = true;
_context.next = 9;
break;
case 30:
_context.next = 36;
break;
case 32:
_context.prev = 32;
_context.t1 = _context['catch'](7);
_didIteratorError = true;
_iteratorError = _context.t1;
case 36:
_context.prev = 36;
_context.prev = 37;
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
case 39:
_context.prev = 39;
if (!_didIteratorError) {
_context.next = 42;
break;
}
throw _iteratorError;
case 42:
return _context.finish(39);
case 43:
return _context.finish(36);
case 44:
return _context.abrupt('return', ignoredStatus);
case 45:
case 'end':
return _context.stop();
}
}
}, _callee, this, [[7, 32, 36, 44], [12, 18], [37,, 39, 43]]);
}));
function isIgnored(_x) {
return _ref2.apply(this, arguments);
}
return isIgnored;
}()
}]);
return GitIgnoreManager;
}();
// @flow
function wrapObject(_ref /*: {type: string, object: Buffer} */) {

@@ -1246,2 +1406,3 @@ var type = _ref.type,

exports.GitIndexManager = GitIndexManager;
exports.GitIgnoreManager = GitIgnoreManager;
exports.GitObjectManager = GitObjectManager;

@@ -1248,0 +1409,0 @@ exports.GitRefsManager = GitRefsManager;

147

dist/for-browserify/utils.js

@@ -421,142 +421,2 @@ 'use strict';

var resolveRef = function () {
var _ref2 = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(_ref) {
var gitdir = _ref.gitdir,
ref = _ref.ref,
depth = _ref.depth;
var sha;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
if (!(depth !== undefined)) {
_context.next = 4;
break;
}
depth--;
if (!(depth === -1)) {
_context.next = 4;
break;
}
return _context.abrupt('return', ref);
case 4:
sha = void 0;
// Is it a ref pointer?
if (!ref.startsWith('ref: ')) {
_context.next = 8;
break;
}
ref = ref.slice('ref: '.length);
return _context.abrupt('return', resolveRef({ gitdir: gitdir, ref: ref, depth: depth }));
case 8:
if (!(ref.length === 40 && /[0-9a-f]{40}/.test(ref))) {
_context.next = 10;
break;
}
return _context.abrupt('return', ref);
case 10:
if (!(ref === 'HEAD' || ref === 'MERGE_HEAD')) {
_context.next = 16;
break;
}
_context.next = 13;
return read(gitdir + '/' + ref, { encoding: 'utf8' });
case 13:
sha = _context.sent;
if (!sha) {
_context.next = 16;
break;
}
return _context.abrupt('return', resolveRef({ gitdir: gitdir, ref: sha.trim(), depth: depth }));
case 16:
if (!ref.startsWith('refs/')) {
_context.next = 22;
break;
}
_context.next = 19;
return read(gitdir + '/' + ref, { encoding: 'utf8' });
case 19:
sha = _context.sent;
if (!sha) {
_context.next = 22;
break;
}
return _context.abrupt('return', resolveRef({ gitdir: gitdir, ref: sha.trim(), depth: depth }));
case 22:
_context.next = 24;
return read(gitdir + '/refs/heads/' + ref, { encoding: 'utf8' });
case 24:
sha = _context.sent;
if (!sha) {
_context.next = 27;
break;
}
return _context.abrupt('return', resolveRef({ gitdir: gitdir, ref: sha.trim(), depth: depth }));
case 27:
_context.next = 29;
return read(gitdir + '/refs/tags/' + ref, { encoding: 'utf8' });
case 29:
sha = _context.sent;
if (!sha) {
_context.next = 32;
break;
}
return _context.abrupt('return', resolveRef({ gitdir: gitdir, ref: sha.trim(), depth: depth }));
case 32:
_context.next = 34;
return read(gitdir + '/refs/remotes/' + ref, { encoding: 'utf8' });
case 34:
sha = _context.sent;
if (!sha) {
_context.next = 37;
break;
}
return _context.abrupt('return', resolveRef({ gitdir: gitdir, ref: sha.trim(), depth: depth }));
case 37:
throw new Error('Could not resolve reference ' + ref);
case 38:
case 'end':
return _context.stop();
}
}
}, _callee, this);
}));
return function resolveRef(_x) {
return _ref2.apply(this, arguments);
};
}();
// @flow

@@ -605,3 +465,3 @@ // An async writeFile variant that automatically creates missing directories,

var name = "isomorphic-git";
var version = "0.0.19";
var version = "0.0.20";
var description = "A pure JavaScript implementation of git for node and browsers!";

@@ -622,4 +482,4 @@ var main = "dist/for-node/";

var files = ["dist", "cli.js"];
var dependencies = { "async-lock": "^1.0.0", "await-stream-ready": "^1.0.1", "babel-runtime": "^6.26.0", "buffer": "^5.0.7", "buffer-peek-stream": "^1.0.1", "buffercursor": "0.0.12", "gartal": "^1.1.2", "git-apply-delta": "0.0.7", "git-list-pack": "0.0.10", "ini": "^1.3.4", "minimisted": "^2.0.0", "openpgp": "^2.5.10", "pad": "^2.0.1", "pako": "^1.0.5", "pify": "^3.0.0", "shasum": "^1.0.2", "simple-concat": "^1.0.0", "simple-get": "^2.7.0", "thru": "git+https://github.com/wmhilton-contrib/thru.git#master" };
var devDependencies = { "babel-plugin-external-helpers": "^6.22.0", "babel-plugin-transform-es2015-modules-commonjs": "^6.24.1", "babel-plugin-transform-object-rest-spread": "^6.23.0", "babel-plugin-transform-runtime": "^6.23.0", "babel-preset-env": "^1.6.0", "babel-preset-flow": "^6.23.0", "ban-sensitive-files": "^1.9.0", "browserfs": "^1.4.3", "browserify": "^14.4.0", "browserify-shim": "^3.8.14", "codecov": "^2.3.0", "doctoc": "^1.3.0", "husky": "^0.14.3", "jest": "^21.2.1", "jest-fixtures": "^0.6.0", "jsonfile": "^4.0.0", "karma": "^1.7.1", "karma-browserify": "^5.1.1", "karma-chrome-launcher": "^2.2.0", "karma-firefox-launcher": "^1.0.1", "karma-sauce-launcher": "^1.2.0", "karma-tap": "^3.1.1", "lodash": "^4.17.4", "nock": "^9.0.17", "npm-run-all": "^4.1.1", "nps": "^5.7.1", "nps-utils": "^1.4.0", "parse-header-stream": "^1.1.1", "prettier-standard": "^7.0.1", "rollup": "^0.50.0", "rollup-plugin-babel": "^3.0.2", "rollup-plugin-json": "^2.3.0", "standard": "^10.0.3", "stream-equal": "^1.0.1", "tape": "^4.8.0", "uglify-es": "^3.1.2", "watchify": "^3.9.0" };
var dependencies = { "async-lock": "^1.0.0", "await-stream-ready": "^1.0.1", "babel-runtime": "^6.26.0", "buffer": "^5.0.7", "buffer-peek-stream": "^1.0.1", "buffercursor": "0.0.12", "gartal": "^1.1.2", "git-apply-delta": "0.0.7", "git-list-pack": "0.0.10", "ignore": "^3.3.6", "ini": "^1.3.4", "minimisted": "^2.0.0", "openpgp": "^2.5.10", "pad": "^2.0.1", "pako": "^1.0.5", "pify": "^3.0.0", "shasum": "^1.0.2", "simple-concat": "^1.0.0", "simple-get": "^2.7.0", "thru": "git+https://github.com/wmhilton-contrib/thru.git#master" };
var devDependencies = { "babel-plugin-external-helpers": "^6.22.0", "babel-plugin-transform-es2015-modules-commonjs": "^6.24.1", "babel-plugin-transform-object-rest-spread": "^6.23.0", "babel-plugin-transform-runtime": "^6.23.0", "babel-preset-env": "^1.6.0", "babel-preset-flow": "^6.23.0", "ban-sensitive-files": "^1.9.0", "browserfs": "^1.4.3", "browserify": "^14.4.0", "browserify-shim": "^3.8.14", "codecov": "^3.0.0", "doctoc": "^1.3.0", "husky": "^0.14.3", "jest": "^21.2.1", "jest-fixtures": "^0.6.0", "jsonfile": "^4.0.0", "karma": "^1.7.1", "karma-browserify": "^5.1.1", "karma-chrome-launcher": "^2.2.0", "karma-firefox-launcher": "^1.0.1", "karma-sauce-launcher": "^1.2.0", "karma-tap": "^3.1.1", "lodash": "^4.17.4", "nock": "^9.0.17", "npm-run-all": "^4.1.1", "nps": "^5.7.1", "nps-utils": "^1.4.0", "parse-header-stream": "^1.1.1", "prettier-standard": "^7.0.1", "rollup": "^0.50.0", "rollup-plugin-babel": "^3.0.2", "rollup-plugin-json": "^2.3.0", "standard": "^10.0.3", "stream-equal": "^1.0.1", "tape": "^4.8.0", "uglify-es": "^3.1.2", "watchify": "^3.9.0" };
var ava = { "source": ["dist/for-node/*"] };

@@ -691,3 +551,2 @@ var browserify = { "transform": ["browserify-shim"] };

exports.read = read;
exports.resolveRef = resolveRef;
exports.sleep = sleep;

@@ -694,0 +553,0 @@ exports.write = write;

import path from 'path';
import pify from 'pify';
import { GitConfigManager, GitIndexManager, GitObjectManager, GitRefsManager, GitRemoteHTTP, GitShallowManager } from './managers.js';
import { flatFileListToDirectoryStructure, fs, mkdirs, pkg, read, resolveRef, rm, write } from './utils.js';
import { GitConfigManager, GitIgnoreManager, GitIndexManager, GitObjectManager, GitRefsManager, GitRemoteHTTP, GitShallowManager } from './managers.js';
import { flatFileListToDirectoryStructure, fs, mkdirs, pkg, read, rm, write } from './utils.js';
import stream from 'stream';

@@ -171,2 +171,42 @@ import thru from 'thru';

async function resolveRef({ gitdir, ref, depth }) {
if (depth !== undefined) {
depth--;
if (depth === -1) {
return ref;
}
}
let sha;
// Is it a ref pointer?
if (ref.startsWith('ref: ')) {
ref = ref.slice('ref: '.length);
return resolveRef({ gitdir, ref, depth });
}
// Is it a complete and valid SHA?
if (ref.length === 40 && /[0-9a-f]{40}/.test(ref)) {
return ref;
}
// Is it a special ref?
if (ref === 'HEAD' || ref === 'MERGE_HEAD') {
sha = await read(`${gitdir}/${ref}`, { encoding: 'utf8' });
if (sha) return resolveRef({ gitdir, ref: sha.trim(), depth });
}
// Is it a full ref?
if (ref.startsWith('refs/')) {
sha = await read(`${gitdir}/${ref}`, { encoding: 'utf8' });
if (sha) return resolveRef({ gitdir, ref: sha.trim(), depth });
}
// Is it a (local) branch?
sha = await read(`${gitdir}/refs/heads/${ref}`, { encoding: 'utf8' });
if (sha) return resolveRef({ gitdir, ref: sha.trim(), depth });
// Is it a tag?
sha = await read(`${gitdir}/refs/tags/${ref}`, { encoding: 'utf8' });
if (sha) return resolveRef({ gitdir, ref: sha.trim(), depth });
// Is it remote branch?
sha = await read(`${gitdir}/refs/remotes/${ref}`, { encoding: 'utf8' });
if (sha) return resolveRef({ gitdir, ref: sha.trim(), depth });
// Do we give up?
throw new Error(`Could not resolve reference ${ref}`);
}
// @flow

@@ -843,2 +883,6 @@ async function fetchPackfile({

}) {
let ignored = await GitIgnoreManager.isIgnored({ gitdir, workdir, pathname });
if (ignored) {
return 'ignored';
}
let headTree = await getHeadTree({ gitdir });

@@ -928,3 +972,3 @@ let treeOid = await getOidAtPath({ gitdir, tree: headTree, path: pathname });

var version$1 = "0.0.19";
var version$1 = "0.0.20";

@@ -935,2 +979,2 @@ function version() {

export { add, clone, checkout, commit, fetch, init, list, listCommits, listObjects, log, pack, push, remove, config, unpack, verify, status, findRoot, listBranches, version };
export { add, clone, checkout, commit, fetch, init, list, listCommits, listObjects, log, pack, push, remove, resolveRef, config, unpack, verify, status, findRoot, listBranches, version };

@@ -5,2 +5,3 @@ import { GitConfig, GitIndex, GitPktLine } from './models.js';

import AsyncLock from 'async-lock';
import ignore from 'ignore';
import { Buffer } from 'buffer';

@@ -97,2 +98,52 @@ import pako from 'pako';

// @flow
// I'm putting this in a Manager because I reckon it could benefit
// from a LOT of cacheing.
class GitIgnoreManager {
static async isIgnored({
gitdir,
workdir,
pathname
}) /*: Promise<Boolean> */{
let pairs = [{
gitignore: path.join(workdir, '.gitignore'),
pathname
}];
let pieces = pathname.split('/');
for (let i = 1; i < pieces.length; i++) {
let dir = pieces.slice(0, i).join('/');
let file = pieces.slice(i).join('/');
pairs.push({
gitignore: path.join(workdir, dir, '.gitignore'),
pathname: file
});
}
let ignoredStatus = false;
for (let p of pairs) {
let file;
try {
file = await read(p.gitignore, 'utf8');
} catch (err) {
if (err.code === 'NOENT') continue;
}
let ign = ignore().add(file);
// If the parent directory is excluded, we are done.
// "It is not possible to re-include a file if a parent directory of that file is excluded. Git doesn’t list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined."
// source: https://git-scm.com/docs/gitignore
let parentdir = path.dirname(p.pathname);
if (ign.ignores(parentdir)) return true;
// If the file is currently ignored, test for UNignoring.
if (ignoredStatus) {
if (!ignore().add(`**\n${file}`).ignores(p.pathname)) {
ignoredStatus = false;
}
} else {
ignoredStatus = ign.ignores(p.pathname);
}
}
return ignoredStatus;
}
}
// @flow
function wrapObject({ type, object /*: {type: string, object: Buffer} */ }) {

@@ -352,2 +403,2 @@ let buffer$$1 = Buffer.concat([Buffer.from(type + ' '), Buffer.from(object.byteLength.toString()), Buffer.from([0]), Buffer.from(object)]);

export { GitConfigManager, GitShallowManager, GitIndexManager, GitObjectManager, GitRefsManager, GitRemoteHTTP };
export { GitConfigManager, GitShallowManager, GitIndexManager, GitIgnoreManager, GitObjectManager, GitRefsManager, GitRemoteHTTP };

@@ -159,42 +159,2 @@ import systemfs from 'fs';

async function resolveRef({ gitdir, ref, depth }) {
if (depth !== undefined) {
depth--;
if (depth === -1) {
return ref;
}
}
let sha;
// Is it a ref pointer?
if (ref.startsWith('ref: ')) {
ref = ref.slice('ref: '.length);
return resolveRef({ gitdir, ref, depth });
}
// Is it a complete and valid SHA?
if (ref.length === 40 && /[0-9a-f]{40}/.test(ref)) {
return ref;
}
// Is it a special ref?
if (ref === 'HEAD' || ref === 'MERGE_HEAD') {
sha = await read(`${gitdir}/${ref}`, { encoding: 'utf8' });
if (sha) return resolveRef({ gitdir, ref: sha.trim(), depth });
}
// Is it a full ref?
if (ref.startsWith('refs/')) {
sha = await read(`${gitdir}/${ref}`, { encoding: 'utf8' });
if (sha) return resolveRef({ gitdir, ref: sha.trim(), depth });
}
// Is it a (local) branch?
sha = await read(`${gitdir}/refs/heads/${ref}`, { encoding: 'utf8' });
if (sha) return resolveRef({ gitdir, ref: sha.trim(), depth });
// Is it a tag?
sha = await read(`${gitdir}/refs/tags/${ref}`, { encoding: 'utf8' });
if (sha) return resolveRef({ gitdir, ref: sha.trim(), depth });
// Is it remote branch?
sha = await read(`${gitdir}/refs/remotes/${ref}`, { encoding: 'utf8' });
if (sha) return resolveRef({ gitdir, ref: sha.trim(), depth });
// Do we give up?
throw new Error(`Could not resolve reference ${ref}`);
}
// @flow

@@ -217,3 +177,3 @@ // An async writeFile variant that automatically creates missing directories,

var name = "isomorphic-git";
var version = "0.0.19";
var version = "0.0.20";
var description = "A pure JavaScript implementation of git for node and browsers!";

@@ -234,4 +194,4 @@ var main = "dist/for-node/";

var files = ["dist", "cli.js"];
var dependencies = { "async-lock": "^1.0.0", "await-stream-ready": "^1.0.1", "babel-runtime": "^6.26.0", "buffer": "^5.0.7", "buffer-peek-stream": "^1.0.1", "buffercursor": "0.0.12", "gartal": "^1.1.2", "git-apply-delta": "0.0.7", "git-list-pack": "0.0.10", "ini": "^1.3.4", "minimisted": "^2.0.0", "openpgp": "^2.5.10", "pad": "^2.0.1", "pako": "^1.0.5", "pify": "^3.0.0", "shasum": "^1.0.2", "simple-concat": "^1.0.0", "simple-get": "^2.7.0", "thru": "git+https://github.com/wmhilton-contrib/thru.git#master" };
var devDependencies = { "babel-plugin-external-helpers": "^6.22.0", "babel-plugin-transform-es2015-modules-commonjs": "^6.24.1", "babel-plugin-transform-object-rest-spread": "^6.23.0", "babel-plugin-transform-runtime": "^6.23.0", "babel-preset-env": "^1.6.0", "babel-preset-flow": "^6.23.0", "ban-sensitive-files": "^1.9.0", "browserfs": "^1.4.3", "browserify": "^14.4.0", "browserify-shim": "^3.8.14", "codecov": "^2.3.0", "doctoc": "^1.3.0", "husky": "^0.14.3", "jest": "^21.2.1", "jest-fixtures": "^0.6.0", "jsonfile": "^4.0.0", "karma": "^1.7.1", "karma-browserify": "^5.1.1", "karma-chrome-launcher": "^2.2.0", "karma-firefox-launcher": "^1.0.1", "karma-sauce-launcher": "^1.2.0", "karma-tap": "^3.1.1", "lodash": "^4.17.4", "nock": "^9.0.17", "npm-run-all": "^4.1.1", "nps": "^5.7.1", "nps-utils": "^1.4.0", "parse-header-stream": "^1.1.1", "prettier-standard": "^7.0.1", "rollup": "^0.50.0", "rollup-plugin-babel": "^3.0.2", "rollup-plugin-json": "^2.3.0", "standard": "^10.0.3", "stream-equal": "^1.0.1", "tape": "^4.8.0", "uglify-es": "^3.1.2", "watchify": "^3.9.0" };
var dependencies = { "async-lock": "^1.0.0", "await-stream-ready": "^1.0.1", "babel-runtime": "^6.26.0", "buffer": "^5.0.7", "buffer-peek-stream": "^1.0.1", "buffercursor": "0.0.12", "gartal": "^1.1.2", "git-apply-delta": "0.0.7", "git-list-pack": "0.0.10", "ignore": "^3.3.6", "ini": "^1.3.4", "minimisted": "^2.0.0", "openpgp": "^2.5.10", "pad": "^2.0.1", "pako": "^1.0.5", "pify": "^3.0.0", "shasum": "^1.0.2", "simple-concat": "^1.0.0", "simple-get": "^2.7.0", "thru": "git+https://github.com/wmhilton-contrib/thru.git#master" };
var devDependencies = { "babel-plugin-external-helpers": "^6.22.0", "babel-plugin-transform-es2015-modules-commonjs": "^6.24.1", "babel-plugin-transform-object-rest-spread": "^6.23.0", "babel-plugin-transform-runtime": "^6.23.0", "babel-preset-env": "^1.6.0", "babel-preset-flow": "^6.23.0", "ban-sensitive-files": "^1.9.0", "browserfs": "^1.4.3", "browserify": "^14.4.0", "browserify-shim": "^3.8.14", "codecov": "^3.0.0", "doctoc": "^1.3.0", "husky": "^0.14.3", "jest": "^21.2.1", "jest-fixtures": "^0.6.0", "jsonfile": "^4.0.0", "karma": "^1.7.1", "karma-browserify": "^5.1.1", "karma-chrome-launcher": "^2.2.0", "karma-firefox-launcher": "^1.0.1", "karma-sauce-launcher": "^1.2.0", "karma-tap": "^3.1.1", "lodash": "^4.17.4", "nock": "^9.0.17", "npm-run-all": "^4.1.1", "nps": "^5.7.1", "nps-utils": "^1.4.0", "parse-header-stream": "^1.1.1", "prettier-standard": "^7.0.1", "rollup": "^0.50.0", "rollup-plugin-babel": "^3.0.2", "rollup-plugin-json": "^2.3.0", "standard": "^10.0.3", "stream-equal": "^1.0.1", "tape": "^4.8.0", "uglify-es": "^3.1.2", "watchify": "^3.9.0" };
var ava = { "source": ["dist/for-node/*"] };

@@ -295,2 +255,2 @@ var browserify = { "transform": ["browserify-shim"] };

export { rm, exists, flatFileListToDirectoryStructure, fs, lock, unlock, mkdirs, read, resolveRef, sleep, write, _package$1 as pkg };
export { rm, exists, flatFileListToDirectoryStructure, fs, lock, unlock, mkdirs, read, sleep, write, _package$1 as pkg };

@@ -177,2 +177,42 @@ 'use strict';

async function resolveRef({ gitdir, ref, depth }) {
if (depth !== undefined) {
depth--;
if (depth === -1) {
return ref;
}
}
let sha;
// Is it a ref pointer?
if (ref.startsWith('ref: ')) {
ref = ref.slice('ref: '.length);
return resolveRef({ gitdir, ref, depth });
}
// Is it a complete and valid SHA?
if (ref.length === 40 && /[0-9a-f]{40}/.test(ref)) {
return ref;
}
// Is it a special ref?
if (ref === 'HEAD' || ref === 'MERGE_HEAD') {
sha = await utils_js.read(`${gitdir}/${ref}`, { encoding: 'utf8' });
if (sha) return resolveRef({ gitdir, ref: sha.trim(), depth });
}
// Is it a full ref?
if (ref.startsWith('refs/')) {
sha = await utils_js.read(`${gitdir}/${ref}`, { encoding: 'utf8' });
if (sha) return resolveRef({ gitdir, ref: sha.trim(), depth });
}
// Is it a (local) branch?
sha = await utils_js.read(`${gitdir}/refs/heads/${ref}`, { encoding: 'utf8' });
if (sha) return resolveRef({ gitdir, ref: sha.trim(), depth });
// Is it a tag?
sha = await utils_js.read(`${gitdir}/refs/tags/${ref}`, { encoding: 'utf8' });
if (sha) return resolveRef({ gitdir, ref: sha.trim(), depth });
// Is it remote branch?
sha = await utils_js.read(`${gitdir}/refs/remotes/${ref}`, { encoding: 'utf8' });
if (sha) return resolveRef({ gitdir, ref: sha.trim(), depth });
// Do we give up?
throw new Error(`Could not resolve reference ${ref}`);
}
// @flow

@@ -231,3 +271,3 @@ async function fetchPackfile({

});
let want = await utils_js.resolveRef({ gitdir, ref: `refs/remotes/${remote}/${ref}` });
let want = await resolveRef({ gitdir, ref: `refs/remotes/${remote}/${ref}` });
// Note: I removed "ofs-delta" from the capabilities list and now

@@ -256,3 +296,3 @@ // Github uses all ref-deltas when I fetch packfiles instead of all ofs-deltas. Nice!

try {
have = await utils_js.resolveRef({ gitdir, ref });
have = await resolveRef({ gitdir, ref });
} catch (err) {}

@@ -355,3 +395,3 @@ if (have) {

if (ref === undefined) {
remoteRef = await utils_js.resolveRef({ gitdir, ref: `${remote}/HEAD`, depth: 2 });
remoteRef = await resolveRef({ gitdir, ref: `${remote}/HEAD`, depth: 2 });
ref = path.basename(remoteRef);

@@ -361,3 +401,3 @@ } else {

}
oid = await utils_js.resolveRef({ gitdir, ref: remoteRef });
oid = await resolveRef({ gitdir, ref: remoteRef });
// Make the remote ref our own!

@@ -369,3 +409,3 @@ await utils_js.write(`${gitdir}/refs/heads/${ref}`, oid + '\n');

}
oid = await utils_js.resolveRef({ gitdir, ref });
oid = await resolveRef({ gitdir, ref });
}

@@ -493,3 +533,3 @@ let commit = await managers_js.GitObjectManager.read({ gitdir, oid });

try {
let parent = await utils_js.resolveRef({ gitdir, ref: 'HEAD' });
let parent = await resolveRef({ gitdir, ref: 'HEAD' });
parents = [parent];

@@ -526,3 +566,3 @@ } catch (err) {

// Update branch pointer
const branch = await utils_js.resolveRef({ gitdir, ref: 'HEAD', depth: 2 });
const branch = await resolveRef({ gitdir, ref: 'HEAD', depth: 2 });
await utils_js.write(path.join(gitdir, branch), oid + '\n');

@@ -619,3 +659,3 @@ });

for (let ref of start) {
startingSet.add((await utils_js.resolveRef({ gitdir, ref })));
startingSet.add((await resolveRef({ gitdir, ref })));
}

@@ -625,3 +665,3 @@ for (let ref of finish) {

try {
let oid = await utils_js.resolveRef({ gitdir, ref });
let oid = await resolveRef({ gitdir, ref });
finishingSet.add(oid);

@@ -710,3 +750,3 @@ } catch (err) {}

let fullRef = ref.startsWith('refs/') ? ref : `refs/heads/${ref}`;
let oid = await utils_js.resolveRef({ gitdir, ref });
let oid = await resolveRef({ gitdir, ref });
let httpRemote = new managers_js.GitRemoteHTTP(url);

@@ -752,3 +792,3 @@ if (authUsername !== undefined && authPassword !== undefined) {

let commits = [];
let start = await utils_js.resolveRef({ gitdir, ref });
let start = await resolveRef({ gitdir, ref });
let { type, object } = await managers_js.GitObjectManager.read({ gitdir, oid: start });

@@ -787,3 +827,3 @@ if (type !== 'commit') {

async function verify({ gitdir, ref, publicKeys }) {
const oid = await utils_js.resolveRef({ gitdir, ref });
const oid = await resolveRef({ gitdir, ref });
const { type, object } = await managers_js.GitObjectManager.read({ gitdir, oid });

@@ -840,3 +880,3 @@ if (type !== 'commit') {

// Get the tree from the HEAD commit.
let oid = await utils_js.resolveRef({ gitdir, ref: 'HEAD' });
let oid = await resolveRef({ gitdir, ref: 'HEAD' });
let { object: cobject } = await managers_js.GitObjectManager.read({ gitdir, oid });

@@ -862,2 +902,6 @@ let commit = models_js.GitCommit.from(cobject);

}) {
let ignored = await managers_js.GitIgnoreManager.isIgnored({ gitdir, workdir, pathname });
if (ignored) {
return 'ignored';
}
let headTree = await getHeadTree({ gitdir });

@@ -947,3 +991,3 @@ let treeOid = await getOidAtPath({ gitdir, tree: headTree, path: pathname });

var version$1 = "0.0.19";
var version$1 = "0.0.20";

@@ -967,2 +1011,3 @@ function version() {

exports.remove = remove;
exports.resolveRef = resolveRef;
exports.config = config;

@@ -969,0 +1014,0 @@ exports.unpack = unpack;

@@ -11,2 +11,3 @@ 'use strict';

var AsyncLock = _interopDefault(require('async-lock'));
var ignore = _interopDefault(require('ignore'));
var buffer = require('buffer');

@@ -103,2 +104,52 @@ var pako = _interopDefault(require('pako'));

// @flow
// I'm putting this in a Manager because I reckon it could benefit
// from a LOT of cacheing.
class GitIgnoreManager {
static async isIgnored({
gitdir,
workdir,
pathname
}) /*: Promise<Boolean> */{
let pairs = [{
gitignore: path.join(workdir, '.gitignore'),
pathname
}];
let pieces = pathname.split('/');
for (let i = 1; i < pieces.length; i++) {
let dir = pieces.slice(0, i).join('/');
let file = pieces.slice(i).join('/');
pairs.push({
gitignore: path.join(workdir, dir, '.gitignore'),
pathname: file
});
}
let ignoredStatus = false;
for (let p of pairs) {
let file;
try {
file = await utils_js.read(p.gitignore, 'utf8');
} catch (err) {
if (err.code === 'NOENT') continue;
}
let ign = ignore().add(file);
// If the parent directory is excluded, we are done.
// "It is not possible to re-include a file if a parent directory of that file is excluded. Git doesn’t list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined."
// source: https://git-scm.com/docs/gitignore
let parentdir = path.dirname(p.pathname);
if (ign.ignores(parentdir)) return true;
// If the file is currently ignored, test for UNignoring.
if (ignoredStatus) {
if (!ignore().add(`**\n${file}`).ignores(p.pathname)) {
ignoredStatus = false;
}
} else {
ignoredStatus = ign.ignores(p.pathname);
}
}
return ignoredStatus;
}
}
// @flow
function wrapObject({ type, object /*: {type: string, object: Buffer} */ }) {

@@ -361,4 +412,5 @@ let buffer$$1 = buffer.Buffer.concat([buffer.Buffer.from(type + ' '), buffer.Buffer.from(object.byteLength.toString()), buffer.Buffer.from([0]), buffer.Buffer.from(object)]);

exports.GitIndexManager = GitIndexManager;
exports.GitIgnoreManager = GitIgnoreManager;
exports.GitObjectManager = GitObjectManager;
exports.GitRefsManager = GitRefsManager;
exports.GitRemoteHTTP = GitRemoteHTTP;

@@ -165,42 +165,2 @@ 'use strict';

async function resolveRef({ gitdir, ref, depth }) {
if (depth !== undefined) {
depth--;
if (depth === -1) {
return ref;
}
}
let sha;
// Is it a ref pointer?
if (ref.startsWith('ref: ')) {
ref = ref.slice('ref: '.length);
return resolveRef({ gitdir, ref, depth });
}
// Is it a complete and valid SHA?
if (ref.length === 40 && /[0-9a-f]{40}/.test(ref)) {
return ref;
}
// Is it a special ref?
if (ref === 'HEAD' || ref === 'MERGE_HEAD') {
sha = await read(`${gitdir}/${ref}`, { encoding: 'utf8' });
if (sha) return resolveRef({ gitdir, ref: sha.trim(), depth });
}
// Is it a full ref?
if (ref.startsWith('refs/')) {
sha = await read(`${gitdir}/${ref}`, { encoding: 'utf8' });
if (sha) return resolveRef({ gitdir, ref: sha.trim(), depth });
}
// Is it a (local) branch?
sha = await read(`${gitdir}/refs/heads/${ref}`, { encoding: 'utf8' });
if (sha) return resolveRef({ gitdir, ref: sha.trim(), depth });
// Is it a tag?
sha = await read(`${gitdir}/refs/tags/${ref}`, { encoding: 'utf8' });
if (sha) return resolveRef({ gitdir, ref: sha.trim(), depth });
// Is it remote branch?
sha = await read(`${gitdir}/refs/remotes/${ref}`, { encoding: 'utf8' });
if (sha) return resolveRef({ gitdir, ref: sha.trim(), depth });
// Do we give up?
throw new Error(`Could not resolve reference ${ref}`);
}
// @flow

@@ -223,3 +183,3 @@ // An async writeFile variant that automatically creates missing directories,

var name = "isomorphic-git";
var version = "0.0.19";
var version = "0.0.20";
var description = "A pure JavaScript implementation of git for node and browsers!";

@@ -240,4 +200,4 @@ var main = "dist/for-node/";

var files = ["dist", "cli.js"];
var dependencies = { "async-lock": "^1.0.0", "await-stream-ready": "^1.0.1", "babel-runtime": "^6.26.0", "buffer": "^5.0.7", "buffer-peek-stream": "^1.0.1", "buffercursor": "0.0.12", "gartal": "^1.1.2", "git-apply-delta": "0.0.7", "git-list-pack": "0.0.10", "ini": "^1.3.4", "minimisted": "^2.0.0", "openpgp": "^2.5.10", "pad": "^2.0.1", "pako": "^1.0.5", "pify": "^3.0.0", "shasum": "^1.0.2", "simple-concat": "^1.0.0", "simple-get": "^2.7.0", "thru": "git+https://github.com/wmhilton-contrib/thru.git#master" };
var devDependencies = { "babel-plugin-external-helpers": "^6.22.0", "babel-plugin-transform-es2015-modules-commonjs": "^6.24.1", "babel-plugin-transform-object-rest-spread": "^6.23.0", "babel-plugin-transform-runtime": "^6.23.0", "babel-preset-env": "^1.6.0", "babel-preset-flow": "^6.23.0", "ban-sensitive-files": "^1.9.0", "browserfs": "^1.4.3", "browserify": "^14.4.0", "browserify-shim": "^3.8.14", "codecov": "^2.3.0", "doctoc": "^1.3.0", "husky": "^0.14.3", "jest": "^21.2.1", "jest-fixtures": "^0.6.0", "jsonfile": "^4.0.0", "karma": "^1.7.1", "karma-browserify": "^5.1.1", "karma-chrome-launcher": "^2.2.0", "karma-firefox-launcher": "^1.0.1", "karma-sauce-launcher": "^1.2.0", "karma-tap": "^3.1.1", "lodash": "^4.17.4", "nock": "^9.0.17", "npm-run-all": "^4.1.1", "nps": "^5.7.1", "nps-utils": "^1.4.0", "parse-header-stream": "^1.1.1", "prettier-standard": "^7.0.1", "rollup": "^0.50.0", "rollup-plugin-babel": "^3.0.2", "rollup-plugin-json": "^2.3.0", "standard": "^10.0.3", "stream-equal": "^1.0.1", "tape": "^4.8.0", "uglify-es": "^3.1.2", "watchify": "^3.9.0" };
var dependencies = { "async-lock": "^1.0.0", "await-stream-ready": "^1.0.1", "babel-runtime": "^6.26.0", "buffer": "^5.0.7", "buffer-peek-stream": "^1.0.1", "buffercursor": "0.0.12", "gartal": "^1.1.2", "git-apply-delta": "0.0.7", "git-list-pack": "0.0.10", "ignore": "^3.3.6", "ini": "^1.3.4", "minimisted": "^2.0.0", "openpgp": "^2.5.10", "pad": "^2.0.1", "pako": "^1.0.5", "pify": "^3.0.0", "shasum": "^1.0.2", "simple-concat": "^1.0.0", "simple-get": "^2.7.0", "thru": "git+https://github.com/wmhilton-contrib/thru.git#master" };
var devDependencies = { "babel-plugin-external-helpers": "^6.22.0", "babel-plugin-transform-es2015-modules-commonjs": "^6.24.1", "babel-plugin-transform-object-rest-spread": "^6.23.0", "babel-plugin-transform-runtime": "^6.23.0", "babel-preset-env": "^1.6.0", "babel-preset-flow": "^6.23.0", "ban-sensitive-files": "^1.9.0", "browserfs": "^1.4.3", "browserify": "^14.4.0", "browserify-shim": "^3.8.14", "codecov": "^3.0.0", "doctoc": "^1.3.0", "husky": "^0.14.3", "jest": "^21.2.1", "jest-fixtures": "^0.6.0", "jsonfile": "^4.0.0", "karma": "^1.7.1", "karma-browserify": "^5.1.1", "karma-chrome-launcher": "^2.2.0", "karma-firefox-launcher": "^1.0.1", "karma-sauce-launcher": "^1.2.0", "karma-tap": "^3.1.1", "lodash": "^4.17.4", "nock": "^9.0.17", "npm-run-all": "^4.1.1", "nps": "^5.7.1", "nps-utils": "^1.4.0", "parse-header-stream": "^1.1.1", "prettier-standard": "^7.0.1", "rollup": "^0.50.0", "rollup-plugin-babel": "^3.0.2", "rollup-plugin-json": "^2.3.0", "standard": "^10.0.3", "stream-equal": "^1.0.1", "tape": "^4.8.0", "uglify-es": "^3.1.2", "watchify": "^3.9.0" };
var ava = { "source": ["dist/for-node/*"] };

@@ -309,5 +269,4 @@ var browserify = { "transform": ["browserify-shim"] };

exports.read = read;
exports.resolveRef = resolveRef;
exports.sleep = sleep;
exports.write = write;
exports.pkg = _package$1;
{
"name": "isomorphic-git",
"version": "0.0.19",
"version": "0.0.20",
"description": "A pure JavaScript implementation of git for node and browsers!",

@@ -47,2 +47,3 @@ "main": "dist/for-node/",

"git-list-pack": "0.0.10",
"ignore": "^3.3.6",
"ini": "^1.3.4",

@@ -70,3 +71,3 @@ "minimisted": "^2.0.0",

"browserify-shim": "^3.8.14",
"codecov": "^2.3.0",
"codecov": "^3.0.0",
"doctoc": "^1.3.0",

@@ -73,0 +74,0 @@ "husky": "^0.14.3",

@@ -6,6 +6,10 @@ # isomorphic-git ![node version](https://img.shields.io/node/v/isomorphic-git.svg) [![Build Status](https://travis-ci.org/wmhilton/isomorphic-git.svg?branch=master)](https://travis-ci.org/wmhilton/isomorphic-git) [![codecov](https://codecov.io/gh/wmhilton/isomorphic-git/branch/master/graph/badge.svg)](https://codecov.io/gh/wmhilton/isomorphic-git) [![dependencies](https://david-dm.org/wmhilton/isomorphic-git/status.svg)](https://david-dm.org/wmhilton/isomorphic-git) [![Known Vulnerabilities](https://snyk.io/test/github/wmhilton/isomorphic-git/badge.svg)](https://snyk.io/test/github/wmhilton/isomorphic-git)

It works with any modern browser (see list above) and uses [BrowserFS](https://www.npmjs.com/package/browserfs) to emulate the node 'fs' module. This means client-side JavaScript can be used to read *and write* to the web the same way you've been editing websites on your desktop since 2008 - using git.
`isomorphic-git` is a pure JavaScript implementation of git that works in node and browser environments (including WebWorkers and ServiceWorkers). This means it can be used to read and write to to git repositories, as well as fetch from and push to git remotes like Github.
Isomorphic-git does not impliment every feature found in the canonical git implementation. But it does aim for 100% compatibility. This means it does all its operations by modifying files in a ".git" directory just like the git you are used to. You can even use the `isogit` CLI to operate on existing git repositories on your desktop or server.
Isomorphic-git aims for 100% interoperability with the canonical git implementation. This means it does all its operations by modifying files in a ".git" directory just like the git you are used to. The included `isogit` CLI can operate on git repositories on your desktop or server.
Unlike earlier git-in-js solutions that were hypermodular, `isomorphic-git` aims to be a complete solution with no assembly required.
The [high-level API](#high-level-git-api) is a [fluent](https://en.wikipedia.org/wiki/Fluent_interface) interface modeled after the git CLI and should feel natural to read and write.
However, one size does not always fit. That's why `isomorphic-git` also has a [layered API](#lower-level-api) that frees you to build a solution using only the exact features you need.
<hr>

@@ -32,2 +36,3 @@

- [.remove(file)](#removefile)
- [.status(file)](#statusfile)
- [.commit(msg)](#commitmsg)

@@ -45,4 +50,3 @@ - [.push(branch)](#pushbranch)

- [Managers](#managers)
- [Models](#models)
- [Utils](#utils)
- [Models and Utils](#models-and-utils)
- [Who is using `isomorphic-git`?](#who-is-using-isomorphic-git)

@@ -455,2 +459,44 @@ - [Similar projects](#similar-projects)

### .status(file)
Tell whether a file has been changed
```js
// JS example
import git from 'isomorphic-git'
git('.')
.status('README.md')
```
```sh
# CLI example
isogit status README.md
```
```js
// Complete API
git()
.workdir(workdir)
.gitdir(gitdir)
.status(filepath)
```
- @param {string} `workdir` - The path to the working directory.
- @param {string} `gitdir` - The path to the git directory.
- @param {string} `filepath` - The path to the file to query.
- @returns `Promise<String>`
The possible return values are:
- `"ignored"` file ignored by a .gitignore rule
- `"unmodified"` file unchanged from HEAD commit
- `"*modified"` file has modifications, not yet staged
- `"*deleted"` file has been removed, but the removal is not yet staged
- `"*added"` file is untracked, not yet staged
- `"absent"` file not present in HEAD commit, staging area, or working dir
- `"modified"` file has modifications, staged
- `"deleted"` file has been removed, staged
- `"added"` previously untracked file, staged
- `"*unmodified"` working dir and HEAD commit match, but index differs
- `"*absent"` file not present in working dir or HEAD commit, but present in the index
### .commit(msg)

@@ -713,8 +759,29 @@ Create a new commit

```
import * as managers from 'isomorphic-git/dist/for-node/commands'
import {
add,
clone,
checkout,
commit,
fetch,
init,
list,
listCommits,
listObjects,
log,
pack,
push,
remove,
resolveRef,
config,
unpack,
verify,
status,
findRoot,
listBranches,
version
} from 'isomorphic-git/dist/for-node/commands'
```
Each command is available as its own file, so hopefully with
a bit of finagling you will be able to import individual commands
if you only need a few and are willint to sacrifice the fluent API
Each command is available as its own file, so you are able to import individual commands
if you only need a few and are willing to sacrifice the fluent API
in order to optimize your bundle size.

@@ -725,3 +792,10 @@

```
import * as managers from 'isomorphic-git/dist/for-node/managers'
import {
GitConfigManager,
GitShallowManager,
GitIndexManager,
GitObjectManager,
GitRefsManager,
GitRemoteHTTP
} from 'isomorphic-git/dist/for-node/managers'
```

@@ -738,19 +812,35 @@

### Models
### Models and Utils
```
import * as models from 'isomorphic-git/dist/for-node/models'
import {
GitCommit,
GitConfig,
GitPktLine,
GitIndex,
GitTree
} from 'isomorphic-git/dist/for-node/models'
```
Models are the lowest level building blocks.
They generally have very few or no dependencies except for `'buffer'`.
Models and utils are the lowest level building blocks.
Models generally have very few or no dependencies except for `'buffer'`.
This makes them portable to many different environments so they can be a useful lowest common denominator.
They do not rely on Utils.
### Utils
```
import * as utils from 'isomorphic-git/dist/for-node/utils'
import {
rm,
flatFileListToDirectoryStructure,
default,
lock,
mkdirs,
read,
sleep,
write,
pkg
} from 'isomorphic-git/dist/for-node/utils'
```
I lied. Utils are actually the lowest level building blocks.
Utils are basically miscellaneous functions.
Some are convenience wrappers for common filesystem operations.

@@ -757,0 +847,0 @@ ## Who is using `isomorphic-git`?

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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