@es-git/http-transport
Advanced tools
Comparing version 0.4.1 to 0.4.2
@@ -10,3 +10,3 @@ import { Ref, Hash } from './types'; | ||
readonly fetch: Fetch; | ||
readonly localRefs: Hash[]; | ||
readonly localRefs: Ref[]; | ||
readonly refspec: string | string[]; | ||
@@ -13,0 +13,0 @@ hasObject(hash: string): Promise<boolean>; |
@@ -24,3 +24,3 @@ var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } | ||
import lsRemote from './lsRemote'; | ||
import differingRefs from './differingRefs'; | ||
import findDifferingRefs from './findDifferingRefs'; | ||
import negotiatePack from './negotiatePack'; | ||
@@ -32,3 +32,3 @@ import composeWantRequest from './composeWantRequest'; | ||
import { unpack } from '@es-git/packfile'; | ||
import remoteToLocal from './remoteToLocal'; | ||
import remotesToLocals from './remotesToLocals'; | ||
import defer from './utils/defer'; | ||
@@ -41,4 +41,5 @@ export default async function fetch({ url, fetch, localRefs, refspec, hasObject, depth, shallows, unshallow }, progress) { | ||
refspec = Array.isArray(refspec) ? refspec : [refspec]; | ||
const wanted = await differingRefs(localRefs, remoteRefs, refspec, hasObject, shallows, unshallow); | ||
if (wanted.length == 0) { | ||
const refs = remotesToLocals(remoteRefs, refspec); | ||
const differingRefs = await findDifferingRefs(localRefs, refs, hasObject); | ||
if (differingRefs.length === 0 && !unshallow) { | ||
return { | ||
@@ -51,3 +52,4 @@ objects: function () { return __asyncGenerator(this, arguments, function* () { }); }(), | ||
} | ||
const negotiate = negotiatePack(wanted, localRefs, shallows, unshallow ? 0x7fffffff : depth); | ||
const wanted = differingRefs.filter(ref => !ref.hasRemote).map(ref => ref.remoteHash).concat(unshallow && shallows || []); | ||
const negotiate = negotiatePack(wanted, localRefs.map(ref => ref.hash), shallows, unshallow ? 0x7fffffff : depth); | ||
const body = composeWantRequest(negotiate, commonCapabilities(capabilities)); | ||
@@ -59,3 +61,3 @@ const response = post(url, 'git-upload-pack', body, fetch); | ||
return { | ||
refs: remoteToLocal(remoteRefs, refspec), | ||
refs: differingRefs.map(ref => ({ name: ref.local, hash: ref.remoteHash })), | ||
objects: unpack(createResult(response, shallow.resolve, unshallow.resolve, progress), progress), | ||
@@ -62,0 +64,0 @@ shallow: shallow.promise, |
@@ -6,2 +6,7 @@ export declare type Hash = string; | ||
} | ||
export interface RemoteLocalRef { | ||
readonly remote: string; | ||
readonly local: string; | ||
readonly hash: string; | ||
} | ||
export interface UploadRequest { | ||
@@ -8,0 +13,0 @@ readonly done: boolean; |
@@ -39,5 +39,5 @@ "use strict"; | ||
var _differingRefs = require("./differingRefs"); | ||
var _findDifferingRefs = require("./findDifferingRefs"); | ||
var _differingRefs2 = _interopRequireDefault(_differingRefs); | ||
var _findDifferingRefs2 = _interopRequireDefault(_findDifferingRefs); | ||
@@ -66,5 +66,5 @@ var _negotiatePack = require("./negotiatePack"); | ||
var _remoteToLocal = require("./remoteToLocal"); | ||
var _remotesToLocals = require("./remotesToLocals"); | ||
var _remoteToLocal2 = _interopRequireDefault(_remoteToLocal); | ||
var _remotesToLocals2 = _interopRequireDefault(_remotesToLocals); | ||
@@ -147,3 +147,3 @@ var _defer = require("./utils/defer"); | ||
var _ref3, capabilities, remoteRefs, wanted, negotiate, body, response, shallow, _unshallow; | ||
var _ref3, capabilities, remoteRefs, refs, differingRefs, wanted, negotiate, body, response, shallow, _unshallow; | ||
@@ -171,10 +171,11 @@ return _regenerator2.default.wrap(function _callee2$(_context2) { | ||
refspec = Array.isArray(refspec) ? refspec : [refspec]; | ||
_context2.next = 10; | ||
return (0, _differingRefs2.default)(localRefs, remoteRefs, refspec, hasObject, shallows, unshallow); | ||
refs = (0, _remotesToLocals2.default)(remoteRefs, refspec); | ||
_context2.next = 11; | ||
return (0, _findDifferingRefs2.default)(localRefs, refs, hasObject); | ||
case 10: | ||
wanted = _context2.sent; | ||
case 11: | ||
differingRefs = _context2.sent; | ||
if (!(wanted.length == 0)) { | ||
_context2.next = 13; | ||
if (!(differingRefs.length === 0 && !unshallow)) { | ||
_context2.next = 14; | ||
break; | ||
@@ -202,4 +203,11 @@ } | ||
case 13: | ||
negotiate = (0, _negotiatePack2.default)(wanted, localRefs, shallows, unshallow ? 0x7fffffff : depth); | ||
case 14: | ||
wanted = differingRefs.filter(function (ref) { | ||
return !ref.hasRemote; | ||
}).map(function (ref) { | ||
return ref.remoteHash; | ||
}).concat(unshallow && shallows || []); | ||
negotiate = (0, _negotiatePack2.default)(wanted, localRefs.map(function (ref) { | ||
return ref.hash; | ||
}), shallows, unshallow ? 0x7fffffff : depth); | ||
body = (0, _composeWantRequest2.default)(negotiate, (0, _commonCapabilities2.default)(capabilities)); | ||
@@ -210,3 +218,5 @@ response = (0, _post2.default)(url, 'git-upload-pack', body, fetch); | ||
return _context2.abrupt("return", { | ||
refs: (0, _remoteToLocal2.default)(remoteRefs, refspec), | ||
refs: differingRefs.map(function (ref) { | ||
return { name: ref.local, hash: ref.remoteHash }; | ||
}), | ||
objects: (0, _packfile.unpack)(createResult(response, shallow.resolve, _unshallow.resolve, progress), progress), | ||
@@ -217,3 +227,3 @@ shallow: shallow.promise, | ||
case 19: | ||
case 21: | ||
case "end": | ||
@@ -220,0 +230,0 @@ return _context2.stop(); |
{ | ||
"name": "@es-git/http-transport", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "", | ||
@@ -42,4 +42,4 @@ "main": "js/index.js", | ||
"dependencies": { | ||
"@es-git/core": "^0.4.0", | ||
"@es-git/packfile": "^0.4.0" | ||
"@es-git/core": "^0.4.2", | ||
"@es-git/packfile": "^0.4.2" | ||
}, | ||
@@ -46,0 +46,0 @@ "devDependencies": { |
import { Ref, HasObject, Hash } from './types'; | ||
import lsRemote, { Fetch as LsRemoteFetch } from './lsRemote'; | ||
import differingRefs from './differingRefs'; | ||
import findDifferingRefs from './findDifferingRefs'; | ||
import negotiatePack from './negotiatePack'; | ||
@@ -10,3 +10,3 @@ import composeWantRequest from './composeWantRequest'; | ||
import { unpack, RawObject } from '@es-git/packfile'; | ||
import remoteToLocal from './remoteToLocal'; | ||
import remotesToLocals from './remotesToLocals'; | ||
import defer from './utils/defer'; | ||
@@ -20,3 +20,3 @@ | ||
readonly fetch : Fetch | ||
readonly localRefs: Hash[] | ||
readonly localRefs: Ref[] | ||
readonly refspec : string | string[] | ||
@@ -44,5 +44,6 @@ hasObject(hash : string) : Promise<boolean> | ||
refspec = Array.isArray(refspec) ? refspec : [refspec]; | ||
const wanted = await differingRefs(localRefs, remoteRefs, refspec, hasObject, shallows, unshallow); | ||
const refs = remotesToLocals(remoteRefs, refspec); | ||
const differingRefs = await findDifferingRefs(localRefs, refs, hasObject); | ||
if(wanted.length == 0){ | ||
if(differingRefs.length === 0 && !unshallow){ | ||
return { | ||
@@ -56,3 +57,5 @@ objects: async function*() : AsyncIterableIterator<RawObject> {}(), | ||
const negotiate = negotiatePack(wanted, localRefs, shallows, unshallow ? 0x7fffffff : depth); | ||
const wanted = differingRefs.filter(ref => !ref.hasRemote).map(ref => ref.remoteHash).concat(unshallow && shallows || [] as string[]); | ||
const negotiate = negotiatePack(wanted, localRefs.map(ref => ref.hash), shallows, unshallow ? 0x7fffffff : depth); | ||
const body = composeWantRequest(negotiate, commonCapabilities(capabilities)); | ||
@@ -64,3 +67,3 @@ const response = post(url, 'git-upload-pack', body, fetch); | ||
return { | ||
refs: remoteToLocal(remoteRefs, refspec), | ||
refs: differingRefs.map(ref => ({name: ref.local, hash: ref.remoteHash})), | ||
objects: unpack(createResult(response, shallow.resolve, unshallow.resolve, progress), progress), | ||
@@ -67,0 +70,0 @@ shallow: shallow.promise, |
@@ -8,2 +8,8 @@ export type Hash = string; | ||
export interface RemoteLocalRef { | ||
readonly remote : string | ||
readonly local : string | ||
readonly hash : string | ||
} | ||
export interface UploadRequest { | ||
@@ -10,0 +16,0 @@ readonly done : boolean |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
328685
138
3605
Updated@es-git/core@^0.4.2
Updated@es-git/packfile@^0.4.2