Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Object.keys(tree).forEach(function (key) {
var entry = tree[key];
// Copy non-rules as-is
if (entry.mode !== modes.exec || !/\.rule$/.test(key)) {
newTree[key] = entry;
return;
}
var childPath = path ? path + "/" + key : key;
var childRule = {
path: childPath,
root: root,
hash: entry.hash
};
key = key.substring(0, key.length - 5);
local[key] = loadRule(childPath, childRule);
});
var entry = tree[part];
var newPath = partial ? partial + "/" + part : part;
// If the child is a commit, make sure it's initialized
if (entry && entry.mode === modes.commit) {
if (!storage.hasRepo(newPath)) {
if (callback) {
return storage.initializeRepo(root, entry.hash, newPath, onLoad);
}
throw new Error("Missing repo at '" + newPath + "'");
}
}
// When in baked mode, always be looking for executable rule entries.
var ruleEntry = tree[part + ".rule"];
if (bake && ruleEntry && ruleEntry.mode === modes.exec) {
// Remember them for future reference.
rules.push({
path: newPath,
root: root,
hash: ruleEntry.hash
});
}
if (!entry) {
// If you get here, the entry didn't match
// In raw-mode this is a no-find.
if (!bake) break;
// In bake mode, look for rule that may serve this path.
return searchRules();
}
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);
var repo = fs.findRepo(row.path);
if (repo.fetch && config.current === config.head) {
actions.push(
{sep:true},
{icon:"cw", label:"Sync with Remote", action: sync }
);
if (config.ahead && config.behind) {
actions.push(
{icon:"upload-cloud", label:"Force push", action: forcePush },
{icon:"trash", label:"Discard Local Commits", action: discardCommits }
);
}
}
}
else if (modes.isFile(row.mode)) {
var label = (row.mode === modes.exec) ?
"Make not Executable" :
"Make Executable";
actions.push(
{sep:true},
{icon:"asterisk", label: label, action: toggleExec}
);
}
if (row.path) actions.push(
{sep:true},
{icon:"pencil", label:"Move " + type, action: moveEntry},
{icon:"docs", label:"Copy " + type, action: copyEntry},
{icon:"trash", label:"Delete " + type, action: removeEntry}
);
if (runtimes.length) {
actions.push({sep:true});
runtimes.forEach(function (runtime) {