Skip to content

Commit

Permalink
index: fix fragments HashRaw
Browse files Browse the repository at this point in the history
  • Loading branch information
fcharlie committed Dec 16, 2024
1 parent 8fa2b2c commit b374d35
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SOURCE_DIR := $(abspath $(dir $(lastword ${MAKEFILE_LIST})))
BUILD_DIR := ${SOURCE_DIR}/_build
BUILD_TIME := $(shell date +'%Y-%m-%dT%H:%M:%S%z')
BUILD_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo 'none')
BUILD_VERSION := $(shell cat VERSION || echo '0.15.0')
BUILD_VERSION := $(shell cat VERSION || echo '0.15.1')
GO_PACKAGES := $(shell go list ./... | grep -v '^${PKG}/mock/' | grep -v '^${PKG}/proto/')
GO_LDFLAGS := -ldflags '-X ${PKG}/pkg/version.version=${BUILD_VERSION} -X ${PKG}/pkg/version.buildTime=${BUILD_TIME} -X ${PKG}/pkg/version.buildCommit=${BUILD_COMMIT}'

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.15.0
0.15.1
2 changes: 1 addition & 1 deletion bali.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "zeta"
summary = "HugeSCM - A next generation cloud-based version control system"
description = "HugeSCM - A next generation cloud-based version control system"
package-name = "alipay-linkc-zeta"
version = "0.15.0"
version = "0.15.1"
license = "MIT"
prefix = "/usr/local"
packager = "江二"
Expand Down
2 changes: 1 addition & 1 deletion cmd/zeta-mc/crate.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "zeta-mc"
description = "zeta-mc - Migrate Git repository to zeta"
destination = "bin"
version = "0.15.0"
version = "0.15.1"
goflags = [
"-ldflags",
"-X github.com/antgroup/hugescm/pkg/version.version=$BUILD_VERSION -X github.com/antgroup/hugescm/pkg/version.buildTime=$BUILD_TIME -X github.com/antgroup/hugescm/pkg/version.buildCommit=$BUILD_COMMIT",
Expand Down
2 changes: 1 addition & 1 deletion cmd/zeta/crate.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "zeta"
description = "HugeSCM - A next generation cloud-based version control system"
destination = "bin"
version = "0.15.0"
version = "0.15.1"
goflags = [
"-ldflags",
"-X github.com/antgroup/hugescm/pkg/version.version=$BUILD_VERSION -X github.com/antgroup/hugescm/pkg/version.buildTime=$BUILD_TIME -X github.com/antgroup/hugescm/pkg/version.buildCommit=$BUILD_COMMIT",
Expand Down
12 changes: 8 additions & 4 deletions modules/merkletrie/index/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Node struct {
children []noder.Noder
isDir bool
skip bool
fragments bool
fragments plumbing.Hash
}

type FragmentsGetter func(ctx context.Context, e *index.Entry) *index.Entry
Expand All @@ -49,8 +49,8 @@ func NewRootNode(ctx context.Context, idx *index.Index, fn FragmentsGetter) node
n := &Node{path: fullpath}
if fullpath == e.Name {
if e.Mode&filemode.Fragments != 0 {
n.fragments = e.Hash
n.entry = fn(ctx, e)
n.fragments = true
} else {
n.entry = e
}
Expand Down Expand Up @@ -90,10 +90,14 @@ func (n *Node) Hash() []byte {
return append(n.entry.Hash[:], n.entry.Mode.Bytes()...)
}

// HashRaw: Get the original Hash of Entry. If it is fragments, get the hash of fragments, otherwise get the hash of blob
func (n *Node) HashRaw() plumbing.Hash {
if n.entry == nil {
return plumbing.ZeroHash
}
if !n.fragments.IsZero() {
return n.fragments
}
return n.entry.Hash
}

Expand All @@ -108,7 +112,7 @@ func (n *Node) TrueMode() filemode.FileMode {
if n.entry == nil {
return filemode.Empty
}
if n.fragments {
if !n.fragments.IsZero() {
return n.entry.Mode | filemode.Fragments
}
return n.entry.Mode
Expand All @@ -119,7 +123,7 @@ func (n *Node) ModifiedAt() time.Time {
}

func (n *Node) IsFragments() bool {
return n.fragments
return !n.fragments.IsZero()
}

func (n *Node) Size() int64 {
Expand Down

0 comments on commit b374d35

Please sign in to comment.