Skip to content

Commit 314b0f8

Browse files
committed
chore: update docs, reconcile with gen types (ordering and s/text/message)
1 parent a03cb60 commit 314b0f8

File tree

6 files changed

+578
-527
lines changed

6 files changed

+578
-527
lines changed

README.md

+69-18
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,8 @@ Git ipld format
33

44
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)
55
[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/)
6-
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
7-
[![Coverage Status](https://codecov.io/gh/ipfs/go-ipld-git/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs/go-ipld-git/branch/master)
8-
[![Travis CI](https://travis-ci.org/ipfs/go-ipld-git.svg?branch=master)](https://travis-ci.org/ipfs/go-ipld-git)
96

10-
> An ipld codec for git objects allowing path traversals across the git graph!
11-
12-
Note: This is WIP and may not be an entirely correct parser.
13-
14-
## Lead Maintainer
15-
16-
[Łukasz Magiera](https://github.com/magik6k)
7+
> An IPLD codec for git objects allowing path traversals across the git graph.
178
189
## Table of Contents
1910

@@ -29,19 +20,49 @@ go get github.com/ipfs/go-ipld-git
2920
```
3021

3122
## About
23+
3224
This is an IPLD codec which handles git objects. Objects are transformed
33-
into IPLD graph in the following way:
25+
into IPLD graph as detailed below. Objects are demonstrated here using both
26+
[IPLD Schemas](https://ipld.io/docs/schemas/) and example JSON forms.
27+
28+
### Commit
29+
30+
```ipldsch
31+
type GpgSig string
32+
33+
type PersonInfo struct {
34+
date String
35+
timezone String
36+
email String
37+
name String
38+
}
39+
40+
type Commit struct {
41+
author optional PersonInfo
42+
committer optional PersonInfo
43+
message String
44+
parents [&Commit]
45+
tree &Tree # see "Tree" section below
46+
encoding optional String
47+
signature optional GpgSig
48+
mergeTag [Tag]
49+
other [String]
50+
}
51+
```
52+
53+
As JSON, real data would look something like:
3454

35-
* Commit:
3655
```json
3756
{
3857
"author": {
39-
"date": "1503667703 +0200",
58+
"date": "1503667703",
59+
"timezone": "+0200",
4060
"email": "author@mail",
4161
"name": "Author Name"
4262
},
4363
"committer": {
44-
"date": "1503667703 +0200",
64+
"date": "1503667703",
65+
"timezone": "+0200",
4566
"email": "author@mail",
4667
"name": "Author Name"
4768
},
@@ -51,10 +72,22 @@ into IPLD graph in the following way:
5172
],
5273
"tree": <LINK>
5374
}
75+
```
76+
77+
### Tag
5478

79+
```ipldsch
80+
type Tag struct {
81+
message String
82+
object &Any
83+
tag String
84+
tagger PersonInfo
85+
tagType String
86+
}
5587
```
5688

57-
* Tag:
89+
As JSON, real data would look something like:
90+
5891
```json
5992
{
6093
"message": "message\n",
@@ -67,12 +100,23 @@ into IPLD graph in the following way:
67100
"email": "author@mail",
68101
"name": "Author Name"
69102
},
70-
"type": "commit"
103+
"tagType": "commit"
71104
}
105+
```
106+
107+
### Tree
108+
109+
```ipldsch
110+
type Tree {String:TreeEntry}
72111
112+
type TreeEntry struct {
113+
mode String
114+
hash &Any
115+
}
73116
```
74117

75-
* Tree:
118+
As JSON, real data would look something like:
119+
76120
```json
77121
{
78122
"file.name": {
@@ -87,11 +131,18 @@ into IPLD graph in the following way:
87131
}
88132
```
89133

134+
### Blob
135+
136+
```ipldsch
137+
type Blob bytes
138+
```
139+
140+
As JSON, real data would look something like:
90141

91-
* Blob:
92142
```json
93143
"<base64 of 'blob <size>\0<data>'>"
94144
```
145+
95146
## Contribute
96147

97148
PRs are welcome!

commit.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func encodeCommit(n ipld.Node, w io.Writer) error {
172172
fmt.Fprintf(buf, " type %s\n", mtag.tagType.x)
173173
fmt.Fprintf(buf, " tag %s\n", mtag.tag.x)
174174
fmt.Fprintf(buf, " tagger %s\n \n", mtag.tagger.GitString())
175-
fmt.Fprintf(buf, "%s", mtag.text.x)
175+
fmt.Fprintf(buf, "%s", mtag.message.x)
176176
}
177177
if c.signature.m == schema.Maybe_Value {
178178
fmt.Fprintln(buf, "gpgsig -----BEGIN PGP SIGNATURE-----")

gen/gen.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,28 @@ func main() {
1818
ts.Accumulate(schema.SpawnList("ListString", "String", false))
1919
ts.Accumulate(schema.SpawnLink("Link"))
2020
ts.Accumulate(schema.SpawnStruct("PersonInfo", []schema.StructField{
21-
schema.SpawnStructField("name", "String", false, false),
22-
schema.SpawnStructField("email", "String", false, false),
2321
schema.SpawnStructField("date", "String", false, false),
2422
schema.SpawnStructField("timezone", "String", false, false),
23+
schema.SpawnStructField("email", "String", false, false),
24+
schema.SpawnStructField("name", "String", false, false),
2525
}, schema.SpawnStructRepresentationMap(map[string]string{})))
2626
ts.Accumulate(schema.SpawnString("GpgSig"))
2727
ts.Accumulate(schema.SpawnStruct("Tag", []schema.StructField{
28+
schema.SpawnStructField("message", "String", false, false),
2829
schema.SpawnStructField("object", "Link", false, false),
29-
schema.SpawnStructField("tagType", "String", false, false),
3030
schema.SpawnStructField("tag", "String", false, false),
3131
schema.SpawnStructField("tagger", "PersonInfo", false, false),
32-
schema.SpawnStructField("text", "String", false, false),
32+
schema.SpawnStructField("tagType", "String", false, false),
3333
}, schema.SpawnStructRepresentationMap(map[string]string{})))
3434
ts.Accumulate(schema.SpawnList("ListTag", "Tag", false))
3535
ts.Accumulate(schema.SpawnLinkReference("LinkCommit", "Commit"))
3636
ts.Accumulate(schema.SpawnList("ListParents", "LinkCommit", false))
3737
ts.Accumulate(schema.SpawnStruct("Commit", []schema.StructField{
38-
schema.SpawnStructField("tree", "LinkTree", false, false),
39-
schema.SpawnStructField("parents", "ListParents", false, false),
40-
schema.SpawnStructField("message", "String", false, false),
4138
schema.SpawnStructField("author", "PersonInfo", true, false),
4239
schema.SpawnStructField("committer", "PersonInfo", true, false),
40+
schema.SpawnStructField("message", "String", false, false),
41+
schema.SpawnStructField("parents", "ListParents", false, false),
42+
schema.SpawnStructField("tree", "LinkTree", false, false),
4343
schema.SpawnStructField("encoding", "String", true, false),
4444
schema.SpawnStructField("signature", "GpgSig", true, false),
4545
schema.SpawnStructField("mergeTag", "ListTag", false, false),

0 commit comments

Comments
 (0)