ipldgit

package
v0.0.0-...-8b9b725 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 7, 2019 License: MIT Imports: 16 Imported by: 4

README

Git ipld format

Coverage Status Travis CI

An ipld codec for git objects allowing path traversals across the git graph!

Note: This is WIP and may not be an entirely correct parser.

Table of Contents

Install

go get github.com/ipfs/go-ipld-git

About

This is an IPLD codec which handles git objects. Objects are transformed into IPLD graph in the following way:

  • Commit:
{
  "author": {
    "date": "1503667703 +0200",
    "email": "author@mail",
    "name": "Author Name"
  },
  "committer": {
    "date": "1503667703 +0200",
    "email": "author@mail",
    "name": "Author Name"
  },
  "message": "Commit Message\n",
  "parents": [
    <LINK>, <LINK>, ...
  ],
  "tree": <LINK>
}

  • Tag:
{
  "message": "message\n",
  "object": {
    "/": "z8mWaJGuvHyZf5uwV8TSYbvSbXP6xS9gR"
  },
  "tag": "tagname",
  "tagger": {
    "date": "1503667703 +0200",
    "email": "author@mail",
    "name": "Author Name"
  },
  "type": "commit"
}

  • Tree:
{
  "file.name": {
    "mode": "100664",
    "hash": <LINK>
  },
  "directoryname": {
    "mode": "40000",
    "hash": <LINK>
  },
  ...
}
  • Blob:
"<base64 of 'blob <size>\0<data>'>"

Contribute

PRs are welcome!

Small note: If editing the Readme, please conform to the standard-readme specification.

License

MIT © Jeromy Johnson

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeBlock

func DecodeBlock(block blocks.Block) (node.Node, error)

func ParseCompressedObject

func ParseCompressedObject(r io.Reader) (node.Node, error)

func ParseObject

func ParseObject(r io.Reader) (node.Node, error)

func ParseObjectFromBuffer

func ParseObjectFromBuffer(b []byte) (node.Node, error)

Types

type Blob

type Blob struct {
	// contains filtered or unexported fields
}

func ReadBlob

func ReadBlob(rd *bufio.Reader) (*Blob, error)

func (*Blob) Cid

func (b *Blob) Cid() cid.Cid

func (*Blob) Copy

func (b *Blob) Copy() node.Node

func (*Blob) GitSha

func (b *Blob) GitSha() []byte
func (b *Blob) Links() []*node.Link

func (*Blob) Loggable

func (b *Blob) Loggable() map[string]interface{}

func (*Blob) MarshalJSON

func (b *Blob) MarshalJSON() ([]byte, error)

func (*Blob) RawData

func (b *Blob) RawData() []byte

func (*Blob) Resolve

func (b *Blob) Resolve(_ []string) (interface{}, []string, error)
func (b *Blob) ResolveLink(_ []string) (*node.Link, []string, error)

func (*Blob) Size

func (b *Blob) Size() (uint64, error)

func (*Blob) Stat

func (b *Blob) Stat() (*node.NodeStat, error)

func (*Blob) String

func (b *Blob) String() string

func (*Blob) Tree

func (b *Blob) Tree(p string, depth int) []string

type Commit

type Commit struct {
	DataSize  string      `json:"-"`
	GitTree   cid.Cid     `json:"tree"`
	Parents   []cid.Cid   `json:"parents"`
	Message   string      `json:"message"`
	Author    *PersonInfo `json:"author"`
	Committer *PersonInfo `json:"committer"`
	Encoding  string      `json:"encoding,omitempty"`
	Sig       *GpgSig     `json:"signature,omitempty"`
	MergeTag  []*MergeTag `json:"mergetag,omitempty"`

	// Other contains all the non-standard headers, such as 'HG:extra'
	Other []string `json:"other,omitempty"`
	// contains filtered or unexported fields
}

func ReadCommit

func ReadCommit(rd *bufio.Reader) (*Commit, error)

func (*Commit) Cid

func (c *Commit) Cid() cid.Cid

func (*Commit) Copy

func (c *Commit) Copy() node.Node

func (*Commit) GitSha

func (c *Commit) GitSha() []byte
func (c *Commit) Links() []*node.Link

func (*Commit) Loggable

func (c *Commit) Loggable() map[string]interface{}

func (*Commit) RawData

func (c *Commit) RawData() []byte

func (*Commit) Resolve

func (c *Commit) Resolve(path []string) (interface{}, []string, error)
func (c *Commit) ResolveLink(path []string) (*node.Link, []string, error)

func (*Commit) Size

func (c *Commit) Size() (uint64, error)

func (*Commit) Stat

func (c *Commit) Stat() (*node.NodeStat, error)

func (*Commit) String

func (c *Commit) String() string

func (*Commit) Tree

func (c *Commit) Tree(p string, depth int) []string

type GpgSig

type GpgSig struct {
	Text string
}

func ReadGpgSig

func ReadGpgSig(rd *bufio.Reader) (*GpgSig, error)

type MergeTag

type MergeTag struct {
	Object cid.Cid     `json:"object"`
	Type   string      `json:"type"`
	Tag    string      `json:"tag"`
	Tagger *PersonInfo `json:"tagger"`
	Text   string      `json:"text"`
}

func ReadMergeTag

func ReadMergeTag(hash []byte, rd *bufio.Reader) (*MergeTag, []byte, error)

type PersonInfo

type PersonInfo struct {
	Name     string
	Email    string
	Date     string
	Timezone string
}

func (*PersonInfo) MarshalJSON

func (pi *PersonInfo) MarshalJSON() ([]byte, error)

func (*PersonInfo) String

func (pi *PersonInfo) String() string

type Tag

type Tag struct {
	Object  cid.Cid     `json:"object"`
	Type    string      `json:"type"`
	Tag     string      `json:"tag"`
	Tagger  *PersonInfo `json:"tagger"`
	Message string      `json:"message"`
	// contains filtered or unexported fields
}

func ReadTag

func ReadTag(rd *bufio.Reader) (*Tag, error)

func (*Tag) Cid

func (t *Tag) Cid() cid.Cid

func (*Tag) Copy

func (t *Tag) Copy() node.Node

func (*Tag) GitSha

func (t *Tag) GitSha() []byte
func (t *Tag) Links() []*node.Link

func (*Tag) Loggable

func (t *Tag) Loggable() map[string]interface{}

func (*Tag) RawData

func (t *Tag) RawData() []byte

func (*Tag) Resolve

func (t *Tag) Resolve(path []string) (interface{}, []string, error)
func (t *Tag) ResolveLink(path []string) (*node.Link, []string, error)

func (*Tag) Size

func (t *Tag) Size() (uint64, error)

func (*Tag) Stat

func (t *Tag) Stat() (*node.NodeStat, error)

func (*Tag) String

func (t *Tag) String() string

func (*Tag) Tree

func (t *Tag) Tree(p string, depth int) []string

type Tree

type Tree struct {
	// contains filtered or unexported fields
}

func ReadTree

func ReadTree(rd *bufio.Reader) (*Tree, error)

func (*Tree) Cid

func (t *Tree) Cid() cid.Cid

func (*Tree) Copy

func (t *Tree) Copy() node.Node

func (*Tree) GitSha

func (t *Tree) GitSha() []byte
func (t *Tree) Links() []*node.Link

func (*Tree) Loggable

func (t *Tree) Loggable() map[string]interface{}

func (*Tree) MarshalJSON

func (t *Tree) MarshalJSON() ([]byte, error)

func (*Tree) RawData

func (t *Tree) RawData() []byte

func (*Tree) Resolve

func (t *Tree) Resolve(p []string) (interface{}, []string, error)
func (t Tree) ResolveLink(path []string) (*node.Link, []string, error)

func (*Tree) Size

func (t *Tree) Size() (uint64, error)

func (*Tree) Stat

func (t *Tree) Stat() (*node.NodeStat, error)

func (*Tree) String

func (t *Tree) String() string

func (*Tree) Tree

func (t *Tree) Tree(p string, depth int) []string

type TreeEntry

type TreeEntry struct {
	Mode string  `json:"mode"`
	Hash cid.Cid `json:"hash"`
	// contains filtered or unexported fields
}

func ReadEntry

func ReadEntry(r *bufio.Reader) (*TreeEntry, error)

func (*TreeEntry) WriteTo

func (te *TreeEntry) WriteTo(w io.Writer) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL