Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (callback) return callback(null, entry);
return entry;
}
// In bake mode
if (!found) return callback();
// Resolve commits to be trees
if (mode === modes.commit) {
if (!check("commit", hash)) return;
mode = modes.tree;
hash = storage.get(hash).tree;
}
// Serve the static blob or tree
var type = modes.toType(mode);
entry.hash = hash;
entry.mode = mode;
var overlays = [];
entry.fetch = function (callback) {
return storage.loadAs(root, type, hash, function (err, result) {
if (err) return callback(err);
if (entry.mode === modes.tree) {
return applyOverlays(result, overlays, callback);
}
callback(null, result);
});
};
if (entry.mode === modes.tree) {
return loadOverlays(overlays, function (err) {
if (err) return callback(err);
callback(null, entry);
return callback();
}
if (entry.path == '/') {
return nextEntry();
}
var entryPath = path.join(repoPath, entry.path);
if (options.onProgress) {
var colorPath = '\x1B[34m' +
entryPath.replace(/\//g, '\x1B[1;34m/\x1B[0;34m') + '\x1B[0m';
options.onProgress(entry.hash + ' ' + colorPath);
}
var entryType = modes.toType(entry.mode);
if (entryType == 'tree') {
return fs.mkdir(entryPath, nextEntry);
} else if (entryType == 'blob') {
return repo.loadAs('blob', entry.hash, function(err, blob) {
if (err) return callback(err);
return fs.writeFile(entryPath, blob, nextEntry);
});
}
// skip commits, because we don't support submodules
if (entryType != 'commit') {
return callback(new Error('Unknown entry mode: ' + entry.mode));
}
return nextEntry();
}
if (callback) return callback(null, entry);
return entry;
}
// In bake mode
if (!found) return callback();
// Resolve commits to be trees
if (mode === modes.commit) {
if (!check("commit", hash)) return;
mode = modes.tree;
hash = storage.get(hash).tree;
}
// Serve the static blob or tree
var type = modes.toType(mode);
entry.hash = hash;
entry.mode = mode;
var overlays = [];
entry.fetch = function (callback) {
return storage.loadAs(root, type, hash, function (err, result) {
if (err) return callback(err);
if (entry.mode === modes.tree) {
return applyOverlays(result, overlays, callback);
}
callback(null, result);
});
};
if (entry.mode === modes.tree) {
return loadOverlays(overlays, function (err) {
if (err) return callback(err);
callback(null, entry);
function deepCopy(source, dest, entry, callback) {
if (!callback) return deepCopy.bind(null, source, dest, entry);
if (entry.mode === modes.commit) return callback();
var type = modes.toType(entry.mode);
source.loadAs(type, entry.hash, function (err, value) {
if (!value) return callback(err || new Error("Missing " + type + " " + entry.hash));
dest.saveAs(type, value, function (err) {
if (err) return callback(err);
if (type !== "tree") return callback();
carallel(Object.keys(value).map(function (name) {
return deepCopy(source, dest, value[name]);
}), callback);
}, entry.hash);
});
}
function updateIcon() {
var value =
(errorMessage ? "icon-attention" :
busy ? "icon-spin1 animate-spin" :
mode === modes.sym ? "icon-link" :
mode === modes.file ? "icon-doc" :
mode === modes.exec ? "icon-cog" :
mode === modes.commit ? "icon-fork" :
open ? "icon-folder-open" : "icon-folder") +
(mode === modes.commit ? " tight" : "");
$.icon.setAttribute("class", value);
var title = modes.toType(mode) + " " + hash;
if (errorMessage) title += "\n" + errorMessage;
$.icon.setAttribute("title", title);
if (mode !== modes.commit) {
if ($.folder) {
$.row.removeChild($.folder);
delete $.folder;
}
}
else {
if (!$.folder) {
$.row.insertBefore(domBuilder(["i$folder"], $), $.icon);
}
$.folder.setAttribute("class", "icon-folder" + (open ? "-open" : ""));
$.folder.setAttribute("title", "tree " + treeHash);
}
if (ahead) {