How to use the js-git/lib/modes.js.sym function in js-git

To help you get started, we’ve selected a few js-git examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github creationix / tedit / src / ui / tree.js View on Github external
function onPath(path) {
          // Write the symlink
          if (path !== row.path) {
            row.call(fs.deleteEntry);
          }
          return row.call(path, fs.writeEntry, {
            mode: modes.sym,
            hash: hash
          });
        }
      }
github creationix / tedit / src / ui / tree.js View on Github external
function onHash(hash) {
        if (row.path === result.path) {
          return onPath(row.path);
        }
        // If the user changed the path, we need to move things
        makeUnique(rootRow, result.path, modes.sym, onPath);
        function onPath(path) {
          // Write the symlink
          if (path !== row.path) {
            row.call(fs.deleteEntry);
          }
          return row.call(path, fs.writeEntry, {
            mode: modes.sym,
            hash: hash
          });
        }
      }
    });
github creationix / tedit / src / git-tree.js View on Github external
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();
          }

          if (bake && (entry.mode === modes.sym)) {
             if (!check("blob", entry.hash)) return;
             var blob = storage.get(entry.hash);
             var link = binary.toUnicode(blob);
             var rest = parts.slice(index + 1).join("/");
             var linkPath = pathJoin(partial, link, rest);
             return resolvePath(linkPath, bake, callback);
          }

          // We're good, move on!
          mode = entry.mode;
          hash = entry.hash;
          partial = newPath;
          if (mode === modes.commit) root = partial;
          index++;
        } else {
          break;
github creationix / tedit / src / git-tree.js View on Github external
readEntry(path, function (err, entry) {
      if (err) return callback(err);
      if (!entry.hash) return callback(err || new Error("Missing entry"));
      if (entry.mode !== modes.sym) return callback("Not a symlink");
      var repo = repos[entry.root];
      repo.loadAs("blob", entry.hash, function (err, blob) {
        if (err) return callback(err);
        try { entry.link = binary.toUnicode(blob); }
        catch (err) { return callback(err); }
        callback(null, entry);
      });
    });
  }
github creationix / tedit / src / js-git / lib / git-fs.js View on Github external
repo.loadAs("blob", entry.hash, function (err, content) {
        if (!content) return callback(err);
        if (entry.mode === modes.sym) {
          content = options.decrypt(content);
        }
        callback(null, content);
      });
    }
github creationix / tedit / src / ui / row.js View on Github external
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 {
github creationix / tedit / src / ui / tree.js View on Github external
row.call(fs.saveAs, "blob", result.target, function (hash) {
      addChild(row, name, modes.sym, hash);
    });
  });
github creationix / tedit / src / js-git / lib / git-fs.js View on Github external
var files = Object.keys(toWrite).map(function (path) {
      var content = toWrite[path];
      delete toWrite[path];
      var mode = modes.blob;
      if (options.shouldEncrypt && options.shouldEncrypt(path)) {
        mode = modes.sym;
        content = options.encrypt(content);
      }
      return {
        path: path,
        mode: mode,
        content: content
      };
    });
    return files;
github creationix / tedit / src / ui / tree.js View on Github external
function activateRow(row, hard) {
  if (row.mode === modes.tree || row.mode === modes.commit) {
    if (openPaths[row.path]) closeTree(row);
    else openTree(row);
  }
  else if (modes.isFile(row.mode)) {
    activateDoc(row, hard);
  }
  else if (row.mode === modes.sym) {
    editSymLink(row);
  }
  else {
    row.fail(new Error("Unknown node mode"));
  }
}