git ssb


cel / ssb-git

Charles E. Lehner committed 1.2.0Latest: 851db48 on 3/3/2022, 12:47:16 AM


Functions for working with git-ssb messages.


var SSBGit = require('ssb-git')

var ssbGit = new SSBGit(sbot, config)

type: Author

Author: {
  name: string,
  email: string,
  localpart: string,
  feed: FeedID,
  date: Date,
  tz: string,

ssbGit.openObject(opts, cb(err, obj))

ssbGit.readObject(obj) : source

ssbGit.statObject(obj), cb(err, stat)

ssbGit.getObjectMsg(opts, cb(err, msg))

ssbGit.getCommit(obj, cb(err, commit))

ssbGit.getTag(obj, cb(err, tag))

ssbGit.readTree(obj) : source

tree entry:

  name: string,
  mode: number,
  hash: sha1,
  type: "tree" | "commit" | "blob",

ssbGit.readTreeFull(obj) : source

Same as readTree except each tree entry also has a msg property which is a ssb message that pushed the tree entry

ssbGit.readCommitChanges(obj, cb)

ssbGit.getObjectAtPath(opts, cb(err, info))

ssbGit.diffFile(opts, cb(err, info))

for a commit and file path, get info about the changes to the file in that commit.

ssbGit.extractSignature(obj, cb(err, parts))

More API

Various utility functions


var mergeUpdates = SSBGit.merge
var KVGraph = require('kvgraph')

mergeUpdates is a reduce function, for use with kvgraph's reduceRight function. The state reduced is as follows:

  refs: [{name: ref, hash: string, link: Msg, title: string},
  refUpdates: {<ref>: integer},


var linearize = SSBGit.linearize()

Call to produce a reduce function, to be used with kvgraph's reduceLeft
function to get an array of the updates to a repo.

NOTE: Each reduce operation has to maintain a small amount of state to stay efficient; call linearize() anew for each reduce operation you wish to do.


Copyright (c) 2016-2019 Charles Lehner and contributors

Usage of the works is permitted provided that this instrument is retained with the works, so that any entity that uses the works is notified of this instrument.


Built with git-ssb-web