aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-05-24 08:16:38 +0000
committerGravatar Runxi Yu2026-05-24 08:16:38 +0000
commitf84f3a3c79b09ad13fdc826933c4c1d8353cdefb (patch)
tree08bbd2a21b2125382fd7b1b5defbaffc2369b34c
parentobject: Fix error handling (diff)
signatureNo signature
object{,/blob,/commit}: Fix lints
-rw-r--r--.golangci.yaml1
-rw-r--r--object/blob/parse.go2
-rw-r--r--object/commit/append.go1
-rw-r--r--object/parse.go8
4 files changed, 5 insertions, 7 deletions
diff --git a/.golangci.yaml b/.golangci.yaml
index 112749b4..b0ff8135 100644
--- a/.golangci.yaml
+++ b/.golangci.yaml
@@ -17,6 +17,7 @@ linters:
- varnamelen # it's rather reasonable to have counters like i, even when it spans quite a bit
- gocyclo # cyclomatic metrics aren't that good
- cyclop # cyclomatic metrics aren't that good
+ - gocognit # too many false positives still
- godox # TODO/etc comments are allowed in our codebase
- funlen # long functions are fine
- dogsled # definitely not an issue, ignoring returns is normal
diff --git a/object/blob/parse.go b/object/blob/parse.go
index b98b0f14..b5522e6a 100644
--- a/object/blob/parse.go
+++ b/object/blob/parse.go
@@ -2,7 +2,7 @@ package blob
// Parse decodes a blob object body.
//
-// Labels: Deps-Owned, Life-Independent
+// Labels: Deps-Owned, Life-Independent.
func Parse(body []byte) (*Blob, error) {
return &Blob{Data: append([]byte(nil), body...)}, nil
}
diff --git a/object/commit/append.go b/object/commit/append.go
index 2bc00573..31031ed1 100644
--- a/object/commit/append.go
+++ b/object/commit/append.go
@@ -31,7 +31,6 @@ func (commit *Commit) AppendWithoutHeader(dst []byte) ([]byte, error) {
for _, h := range commit.ExtraHeaders {
// GIGO on empty keys and such.
-
dst = append(dst, []byte(h.Key)...)
dst = append(dst, byte(' '))
dst = append(dst, h.Value...)
diff --git a/object/parse.go b/object/parse.go
index a4d0d350..6fbaa9b9 100644
--- a/object/parse.go
+++ b/object/parse.go
@@ -8,15 +8,13 @@ import (
"codeberg.org/lindenii/furgit/object/header"
"codeberg.org/lindenii/furgit/object/id"
"codeberg.org/lindenii/furgit/object/typ"
- // "codeberg.org/lindenii/furgit/object/tag"
- // "codeberg.org/lindenii/furgit/object/tree"
)
// SizeMismatchError indicates a mismatch
// between the size expected from the object header
// and the size of the object.
type SizeMismatchError struct {
- Expected int
+ Expected uint64
Got int
}
@@ -34,12 +32,12 @@ func (sizeMismatchError SizeMismatchError) Error() string {
func ParseWithHeader(raw []byte, algo id.Algorithm) (Object, error) {
ty, size, headerLen, err := header.Parse(raw)
if err != nil {
- return nil, err
+ return nil, err //nolint:wrapcheck
}
body := raw[headerLen:]
if uint64(len(body)) != size {
- return nil, SizeMismatchError{Expected: int(size), Got: len(body)}
+ return nil, SizeMismatchError{Expected: size, Got: len(body)}
}
return ParseWithoutHeader(ty, body, algo)