From e7fc07423e76f9bacf27f3f9b19bd676b762c394 Mon Sep 17 00:00:00 2001 From: Kevin Atkinson Date: Wed, 5 Sep 2018 03:09:04 -0400 Subject: [PATCH] gx update and fix code to use new Cid type --- blob.go | 2 +- commit.go | 10 +++++----- git.go | 6 +++--- git_test.go | 4 ++-- package.json | 12 ++++++------ tag.go | 6 +++--- tree.go | 6 +++--- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/blob.go b/blob.go index 2263804..6c782de 100644 --- a/blob.go +++ b/blob.go @@ -10,7 +10,7 @@ import ( type Blob []byte -func (b Blob) Cid() *cid.Cid { +func (b Blob) Cid() cid.Cid { c, _ := cid.Prefix{ MhType: mh.SHA1, MhLength: -1, diff --git a/commit.go b/commit.go index 79a0998..c0810c5 100644 --- a/commit.go +++ b/commit.go @@ -14,8 +14,8 @@ import ( type Commit struct { DataSize string `json:"-"` - GitTree *cid.Cid `json:"tree"` - Parents []*cid.Cid `json:"parents"` + GitTree cid.Cid `json:"tree"` + Parents []cid.Cid `json:"parents"` Message string `json:"message"` Author *PersonInfo `json:"author"` Committer *PersonInfo `json:"committer"` @@ -26,7 +26,7 @@ type Commit struct { // Other contains all the non-standard headers, such as 'HG:extra' Other []string `json:"other,omitempty"` - cid *cid.Cid + cid cid.Cid } type PersonInfo struct { @@ -80,7 +80,7 @@ func (pi *PersonInfo) resolve(p []string) (interface{}, []string, error) { } type MergeTag struct { - Object *cid.Cid `json:"object"` + Object cid.Cid `json:"object"` Type string `json:"type"` Tag string `json:"tag"` Tagger *PersonInfo `json:"tagger"` @@ -91,7 +91,7 @@ type GpgSig struct { Text string } -func (c *Commit) Cid() *cid.Cid { +func (c *Commit) Cid() cid.Cid { return c.cid } diff --git a/git.go b/git.go index 3adf646..7d4f27b 100644 --- a/git.go +++ b/git.go @@ -248,7 +248,7 @@ func ReadTag(rd *bufio.Reader) (*Tag, error) { return out, nil } -func hashObject(data []byte) *cid.Cid { +func hashObject(data []byte) cid.Cid { c, err := cid.Prefix{ MhType: mh.SHA1, MhLength: -1, @@ -437,12 +437,12 @@ func ReadTree(rd *bufio.Reader) (*Tree, error) { return t, nil } -func cidToSha(c *cid.Cid) []byte { +func cidToSha(c cid.Cid) []byte { h := c.Hash() return h[len(h)-20:] } -func shaToCid(sha []byte) *cid.Cid { +func shaToCid(sha []byte) cid.Cid { h, _ := mh.Encode(sha, mh.SHA1) return cid.NewCidV1(cid.GitRaw, h) } diff --git a/git_test.go b/git_test.go index 60eb8d0..b0e0b7e 100644 --- a/git_test.go +++ b/git_test.go @@ -171,7 +171,7 @@ func testNode(t *testing.T, nd node.Node) error { /*s, _ := commit.Size() assert.Equal(t, len(commit.RawData()), int(s))*/ //TODO: Known breakage - assert(t, commit.GitTree != nil) + assert(t, commit.GitTree.Defined()) assert(t, commit.Links() != nil) assert(t, commit.Loggable()["type"] == "git_commit") @@ -228,7 +228,7 @@ func testNode(t *testing.T, nd node.Node) error { } assert(t, tag.Type == "commit" || tag.Type == "tree" || tag.Type == "blob" || tag.Type == "tag") - assert(t, tag.Object != nil) + assert(t, tag.Object.Defined()) assert(t, tag.Loggable()["type"] == "git_tag") assert(t, tag.Tree("", -1) != nil) obj, rest, err := tag.ResolveLink([]string{"object", "aoeu"}) diff --git a/package.json b/package.json index e3ebb46..0e6dfaa 100644 --- a/package.json +++ b/package.json @@ -9,21 +9,21 @@ "gxDependencies": [ { "author": "whyrusleeping", - "hash": "QmX5CsuHyVZeTLxgRSYkgLSDQKb9UjE8xnhQzCEJWWWFsC", + "hash": "QmPjakEcPeSjEfTsDA67gJMv6DdjUniTs2D4xNeCHrkaRQ", "name": "go-ipld-format", - "version": "0.5.8" + "version": "0.6.0" }, { "author": "whyrusleeping", - "hash": "QmZFbDTY9jfSBms2MchvYM9oYRbAF19K7Pby47yDBfpPrb", + "hash": "QmRZ98Qjb3zafYMeebvG7iy53zu4LScLDzpyLcgUZoMP2K", "name": "go-cid", - "version": "0.8.0" + "version": "1.0.0" }, { "author": "stebalien", - "hash": "QmWAzSEoqZ6xU6pu8yL8e5WaMb7wtbfbhhN4p1DknUPtr3", + "hash": "QmbcP1kwkYWM1QndZF1g4aKis3yX8kfAUZmusM52fg2SVC", "name": "go-block-format", - "version": "0.1.11" + "version": "0.2.0" }, { "author": "multiformats", diff --git a/tag.go b/tag.go index 6d29883..4bee947 100644 --- a/tag.go +++ b/tag.go @@ -11,17 +11,17 @@ import ( ) type Tag struct { - Object *cid.Cid `json:"object"` + Object cid.Cid `json:"object"` Type string `json:"type"` Tag string `json:"tag"` Tagger *PersonInfo `json:"tagger"` Message string `json:"message"` dataSize string - cid *cid.Cid + cid cid.Cid } -func (t *Tag) Cid() *cid.Cid { +func (t *Tag) Cid() cid.Cid { return t.cid } diff --git a/tree.go b/tree.go index ca83a48..5907383 100644 --- a/tree.go +++ b/tree.go @@ -15,16 +15,16 @@ type Tree struct { entries map[string]*TreeEntry size int order []string - cid *cid.Cid + cid cid.Cid } type TreeEntry struct { name string Mode string `json:"mode"` - Hash *cid.Cid `json:"hash"` + Hash cid.Cid `json:"hash"` } -func (t *Tree) Cid() *cid.Cid { +func (t *Tree) Cid() cid.Cid { return t.cid }