How to use the js-git/lib/modes.js.toType 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 / git-tree.js View on Github external
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);
github creationix / tedit / src / git-tree.js View on Github external
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);
    });
  }
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 {
      if (!$.folder) {
        $.row.insertBefore(domBuilder(["i$folder"], $), $.icon);
      }
      $.folder.setAttribute("class", "icon-folder" + (open ? "-open" : ""));
      $.folder.setAttribute("title", "tree " + treeHash);
    }
    if (ahead) {
github creationix / tedit / src / js-git / mixins / walkers.js View on Github external
function treeLoadKey(entry, callback) {
    if (entry.mode !== modes.tree) return callback(null, entry);
    var type = modes.toType(entry.mode);
    return repo.loadAs(type, entry.hash, function (err, body) {
      if (err) return callback(err);
      entry.body = body;
      return callback(null, entry);
    });
  }