Skip to content

Commit 5200aad

Browse files
committed
Further minimise changes to current release
* mergeTag -> mergetag * tagType -> type
1 parent 4e0e59b commit 5200aad

9 files changed

+3361
-3347
lines changed

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ type PersonInfo struct {
3838
}
3939
4040
type Commit struct {
41+
tree &Tree # see "Tree" section below
42+
parents [&Commit]
43+
message String
4144
author optional PersonInfo
4245
committer optional PersonInfo
43-
message String
44-
parents [&Commit]
45-
tree &Tree # see "Tree" section below
4646
encoding optional String
4747
signature optional GpgSig
48-
mergeTag [Tag]
48+
mergetag [Tag]
4949
other [String]
5050
}
5151
```
@@ -78,11 +78,11 @@ As JSON, real data would look something like:
7878

7979
```ipldsch
8080
type Tag struct {
81-
message String
8281
object &Any
82+
type String
8383
tag String
8484
tagger PersonInfo
85-
tagType String
85+
message String
8686
}
8787
```
8888

commit.go

+6-8
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ func DecodeCommit(na ipld.NodeAssembler, rd *bufio.Reader) error {
2323
}
2424

2525
c := _Commit{
26-
parents: _ListParents{[]_LinkCommit{}},
27-
mergeTag: _ListTag{[]_Tag{}},
28-
other: _ListString{[]_String{}},
26+
parents: _Commit_Link_List{[]_Commit_Link{}},
2927
}
3028
for {
3129
line, _, err := rd.ReadLine()
@@ -53,14 +51,14 @@ func decodeCommitLine(c Commit, line []byte, rd *bufio.Reader) error {
5351
return err
5452
}
5553

56-
c.tree = _LinkTree{cidlink.Link{Cid: shaToCid(sha)}}
54+
c.tree = _Tree_Link{cidlink.Link{Cid: shaToCid(sha)}}
5755
case bytes.HasPrefix(line, []byte("parent ")):
5856
psha, err := hex.DecodeString(string(line[7:]))
5957
if err != nil {
6058
return err
6159
}
6260

63-
c.parents.x = append(c.parents.x, _LinkCommit{cidlink.Link{Cid: shaToCid(psha)}})
61+
c.parents.x = append(c.parents.x, _Commit_Link{cidlink.Link{Cid: shaToCid(psha)}})
6462
case bytes.HasPrefix(line, []byte("author ")):
6563
a, err := parsePersonInfo(line)
6664
if err != nil {
@@ -88,7 +86,7 @@ func decodeCommitLine(c Commit, line []byte, rd *bufio.Reader) error {
8886
return err
8987
}
9088

91-
c.mergeTag.x = append(c.mergeTag.x, *mt)
89+
c.mergetag.x = append(c.mergetag.x, *mt)
9290

9391
if rest != nil {
9492
err = decodeCommitLine(c, rest, rd)
@@ -167,9 +165,9 @@ func encodeCommit(n ipld.Node, w io.Writer) error {
167165
if c.encoding.m == schema.Maybe_Value {
168166
fmt.Fprintf(buf, "encoding %s\n", c.encoding.v.x)
169167
}
170-
for _, mtag := range c.mergeTag.x {
168+
for _, mtag := range c.mergetag.x {
171169
fmt.Fprintf(buf, "mergetag object %s\n", hex.EncodeToString(mtag.object.sha()))
172-
fmt.Fprintf(buf, " type %s\n", mtag.tagType.x)
170+
fmt.Fprintf(buf, " type %s\n", mtag.typ.x)
173171
fmt.Fprintf(buf, " tag %s\n", mtag.tag.x)
174172
fmt.Fprintf(buf, " tagger %s\n \n", mtag.tagger.GitString())
175173
fmt.Fprintf(buf, "%s", mtag.message.x)

gen/gen.go

+24-12
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,57 @@ func main() {
1313
ts.Init()
1414
adjCfg := &gengo.AdjunctCfg{
1515
CfgUnionMemlayout: map[schema.TypeName]string{},
16+
FieldSymbolLowerOverrides: map[gengo.FieldTuple]string{
17+
{TypeName: "Tag", FieldName: "type"}: "typ",
18+
},
1619
}
20+
1721
ts.Accumulate(schema.SpawnString("String"))
18-
ts.Accumulate(schema.SpawnList("ListString", "String", false))
1922
ts.Accumulate(schema.SpawnLink("Link"))
23+
24+
ts.Accumulate(schema.SpawnList("String_List", "String", false))
25+
2026
ts.Accumulate(schema.SpawnStruct("PersonInfo", []schema.StructField{
2127
schema.SpawnStructField("date", "String", false, false),
2228
schema.SpawnStructField("timezone", "String", false, false),
2329
schema.SpawnStructField("email", "String", false, false),
2430
schema.SpawnStructField("name", "String", false, false),
2531
}, schema.SpawnStructRepresentationMap(map[string]string{})))
32+
2633
ts.Accumulate(schema.SpawnString("GpgSig"))
34+
2735
ts.Accumulate(schema.SpawnStruct("Tag", []schema.StructField{
28-
schema.SpawnStructField("message", "String", false, false),
2936
schema.SpawnStructField("object", "Link", false, false),
37+
schema.SpawnStructField("type", "String", false, false),
3038
schema.SpawnStructField("tag", "String", false, false),
3139
schema.SpawnStructField("tagger", "PersonInfo", false, false),
32-
schema.SpawnStructField("tagType", "String", false, false),
40+
schema.SpawnStructField("message", "String", false, false),
3341
}, schema.SpawnStructRepresentationMap(map[string]string{})))
34-
ts.Accumulate(schema.SpawnList("ListTag", "Tag", false))
35-
ts.Accumulate(schema.SpawnLinkReference("LinkCommit", "Commit"))
36-
ts.Accumulate(schema.SpawnList("ListParents", "LinkCommit", false))
42+
43+
ts.Accumulate(schema.SpawnList("Tag_List", "Tag", false))
44+
3745
ts.Accumulate(schema.SpawnStruct("Commit", []schema.StructField{
46+
schema.SpawnStructField("tree", "Tree_Link", false, false),
47+
schema.SpawnStructField("parents", "Commit_Link_List", false, false),
48+
schema.SpawnStructField("message", "String", false, false),
3849
schema.SpawnStructField("author", "PersonInfo", true, false),
3950
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),
4351
schema.SpawnStructField("encoding", "String", true, false),
4452
schema.SpawnStructField("signature", "GpgSig", true, false),
45-
schema.SpawnStructField("mergeTag", "ListTag", false, false),
46-
schema.SpawnStructField("other", "ListString", false, false),
53+
schema.SpawnStructField("mergetag", "Tag_List", false, false),
54+
schema.SpawnStructField("other", "String_List", false, false),
4755
}, schema.SpawnStructRepresentationMap(map[string]string{})))
56+
ts.Accumulate(schema.SpawnLinkReference("Commit_Link", "Commit"))
57+
ts.Accumulate(schema.SpawnList("Commit_Link_List", "Commit_Link", false))
58+
4859
ts.Accumulate(schema.SpawnBytes("Blob"))
60+
4961
ts.Accumulate(schema.SpawnMap("Tree", "String", "TreeEntry", false))
50-
ts.Accumulate(schema.SpawnLinkReference("LinkTree", "Tree"))
5162
ts.Accumulate(schema.SpawnStruct("TreeEntry", []schema.StructField{
5263
schema.SpawnStructField("mode", "String", false, false),
5364
schema.SpawnStructField("hash", "Link", false, false),
5465
}, schema.SpawnStructRepresentationMap(map[string]string{})))
66+
ts.Accumulate(schema.SpawnLinkReference("Tree_Link", "Tree"))
5567

5668
if errs := ts.ValidateGraph(); errs != nil {
5769
for _, err := range errs {

git_test.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ func testNode(t *testing.T, nd ipld.Node) error {
209209
t.Fatalf("Tag is not a tag")
210210
}
211211

212-
tt, err := tag.tagType.AsString()
212+
tt, err := tag.typ.AsString()
213213
assert(t, err == nil)
214214

215215
assert(t, tt == "commit" || tt == "tree" || tt == "blob" || tt == "tag")
@@ -222,7 +222,11 @@ func testNode(t *testing.T, nd ipld.Node) error {
222222
}
223223

224224
assert(t, len(tree.m) > 0)
225+
226+
default:
227+
return fmt.Errorf("unexpected or unknown NodePrototype %v", nd.Prototype())
225228
}
229+
226230
return nil
227231
}
228232

0 commit comments

Comments
 (0)