isomorphic-git
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -613,3 +613,3 @@ 'use strict'; | ||
var name = "isomorphic-git"; | ||
var version = "0.0.8"; | ||
var version = "0.0.9"; | ||
var description = "Node library for interacting with git repositories, circa 2017"; | ||
@@ -616,0 +616,0 @@ var main = "dist/for-node/"; |
@@ -29,3 +29,3 @@ import path from 'path'; | ||
async function writeTreeToDisk({ gitdir, index, dirpath, tree }) { | ||
async function writeTreeToDisk({ gitdir, workdir, index, prefix, tree }) { | ||
for (let entry of tree) { | ||
@@ -36,15 +36,26 @@ let { type, object } = await GitObjectManager.read({ | ||
}); | ||
let entrypath = `${dirpath}/${entry.path}`; | ||
let entrypath = path.posix.join(prefix, entry.path); | ||
let filepath = path.join(workdir, prefix, entry.path); | ||
switch (type) { | ||
case 'blob': | ||
await write(entrypath, object); | ||
let stats = await pify(fs().lstat)(entrypath); | ||
index.insert({ filepath: entrypath, stats, oid: entry.oid }); | ||
await write(filepath, object); | ||
let stats = await pify(fs().lstat)(filepath); | ||
index.insert({ | ||
filepath: entrypath, | ||
stats, | ||
oid: entry.oid | ||
}); | ||
break; | ||
case 'tree': | ||
let tree = GitTree.from(object); | ||
await writeTreeToDisk({ gitdir, index, dirpath: entrypath, tree }); | ||
await writeTreeToDisk({ | ||
gitdir, | ||
workdir, | ||
index, | ||
prefix: entrypath, | ||
tree | ||
}); | ||
break; | ||
default: | ||
throw new Error(`Unexpected object type ${type} found in tree for '${dirpath}'`); | ||
throw new Error(`Unexpected object type ${type} found in tree for '${entrypath}'`); | ||
} | ||
@@ -77,3 +88,3 @@ } | ||
// Write files. TODO: Write them atomically | ||
await writeTreeToDisk({ gitdir, index, dirpath: workdir, tree }); | ||
await writeTreeToDisk({ gitdir, workdir, index, prefix: '', tree }); | ||
// Update HEAD TODO: Handle non-branch cases | ||
@@ -80,0 +91,0 @@ write(`${gitdir}/HEAD`, `ref: refs/heads/${ref}`); |
@@ -218,3 +218,3 @@ import systemfs from 'fs'; | ||
var name = "isomorphic-git"; | ||
var version = "0.0.8"; | ||
var version = "0.0.9"; | ||
var description = "Node library for interacting with git repositories, circa 2017"; | ||
@@ -221,0 +221,0 @@ var main = "dist/for-node/"; |
@@ -35,3 +35,3 @@ 'use strict'; | ||
async function writeTreeToDisk({ gitdir, index, dirpath, tree }) { | ||
async function writeTreeToDisk({ gitdir, workdir, index, prefix, tree }) { | ||
for (let entry of tree) { | ||
@@ -42,15 +42,26 @@ let { type, object } = await managers_js.GitObjectManager.read({ | ||
}); | ||
let entrypath = `${dirpath}/${entry.path}`; | ||
let entrypath = path.posix.join(prefix, entry.path); | ||
let filepath = path.join(workdir, prefix, entry.path); | ||
switch (type) { | ||
case 'blob': | ||
await utils_js.write(entrypath, object); | ||
let stats = await pify(utils_js.fs().lstat)(entrypath); | ||
index.insert({ filepath: entrypath, stats, oid: entry.oid }); | ||
await utils_js.write(filepath, object); | ||
let stats = await pify(utils_js.fs().lstat)(filepath); | ||
index.insert({ | ||
filepath: entrypath, | ||
stats, | ||
oid: entry.oid | ||
}); | ||
break; | ||
case 'tree': | ||
let tree = models_js.GitTree.from(object); | ||
await writeTreeToDisk({ gitdir, index, dirpath: entrypath, tree }); | ||
await writeTreeToDisk({ | ||
gitdir, | ||
workdir, | ||
index, | ||
prefix: entrypath, | ||
tree | ||
}); | ||
break; | ||
default: | ||
throw new Error(`Unexpected object type ${type} found in tree for '${dirpath}'`); | ||
throw new Error(`Unexpected object type ${type} found in tree for '${entrypath}'`); | ||
} | ||
@@ -83,3 +94,3 @@ } | ||
// Write files. TODO: Write them atomically | ||
await writeTreeToDisk({ gitdir, index, dirpath: workdir, tree }); | ||
await writeTreeToDisk({ gitdir, workdir, index, prefix: '', tree }); | ||
// Update HEAD TODO: Handle non-branch cases | ||
@@ -86,0 +97,0 @@ utils_js.write(`${gitdir}/HEAD`, `ref: refs/heads/${ref}`); |
@@ -224,3 +224,3 @@ 'use strict'; | ||
var name = "isomorphic-git"; | ||
var version = "0.0.8"; | ||
var version = "0.0.9"; | ||
var description = "Node library for interacting with git repositories, circa 2017"; | ||
@@ -227,0 +227,0 @@ var main = "dist/for-node/"; |
{ | ||
"name": "isomorphic-git", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "Node library for interacting with git repositories, circa 2017", | ||
@@ -5,0 +5,0 @@ "main": "dist/for-node/", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
1528384
13415