Skip to content

Commit

Permalink
gx update and fix code to use new Cid type
Browse files Browse the repository at this point in the history
  • Loading branch information
kevina committed Sep 7, 2018
1 parent 18aab30 commit e7fc074
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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 {
Expand Down Expand Up @@ -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"`
Expand All @@ -91,7 +91,7 @@ type GpgSig struct {
Text string
}

func (c *Commit) Cid() *cid.Cid {
func (c *Commit) Cid() cid.Cid {
return c.cid
}

Expand Down
6 changes: 3 additions & 3 deletions git.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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"})
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
6 changes: 3 additions & 3 deletions tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit e7fc074

Please sign in to comment.