Skip to content

Commit 93f46f4

Browse files
committed
Fix bug
1 parent d7e863e commit 93f46f4

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

modules/git/commit_info_nogogit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func GetLastCommitForPaths(ctx context.Context, commit *Commit, treePath string,
153153
if typ != "commit" {
154154
return nil, fmt.Errorf("unexpected type: %s for commit id: %s", typ, commitID)
155155
}
156-
c, err = CommitFromReader(commit.repo, commit.ID, io.LimitReader(batchReader, size))
156+
c, err = CommitFromReader(commit.repo, MustIDFromString(commit.ID.Type(), commitID), io.LimitReader(batchReader, size))
157157
if err != nil {
158158
return nil, err
159159
}

modules/git/object_id.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,21 @@ func EmptyObjectID(objectFormatName string) (ObjectID, error) {
4747
return nil, errors.New("unsupported hash type")
4848
}
4949

50-
func MustID(objectFormat ObjectFormat, b []byte) ObjectID {
51-
objectID, _ := EmptyObjectID(objectFormat.Name())
52-
objectID.SetRawValue(b)
53-
return objectID
54-
}
55-
5650
func IDFromRaw(h ObjectFormat, b []byte) (ObjectID, error) {
5751
if len(b) != h.FullLength()/2 {
5852
return h.EmptyObjectID(), fmt.Errorf("length must be %d: %v", h.FullLength(), b)
5953
}
60-
return MustID(h, b), nil
54+
objectID, err := EmptyObjectID(h.Name())
55+
if err != nil {
56+
return nil, err
57+
}
58+
objectID.SetRawValue(b)
59+
return objectID, nil
60+
}
61+
62+
func MustID(objectFormat ObjectFormat, b []byte) ObjectID {
63+
objectID, _ := IDFromRaw(objectFormat, b)
64+
return objectID
6165
}
6266

6367
func MustIDFromString(h ObjectFormat, s string) ObjectID {

0 commit comments

Comments
 (0)