Skip to content

Commit 7776509

Browse files
committed
fix
1 parent 439ebe7 commit 7776509

File tree

6 files changed

+141
-132
lines changed

6 files changed

+141
-132
lines changed

modules/optional/option.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ package optional
55

66
import "strconv"
77

8+
// Option is a generic type that can hold a value of type T or be empty (None).
9+
//
10+
// It must use the slice type to work with "chi" form values binding:
11+
// * non-existing value are represented as an empty slice (None)
12+
// * existing value is represented as a slice with one element (Some)
13+
// * multiple values are represented as a slice with multiple elements (Some), the Value is the first element (not well-defined in this case)
814
type Option[T any] []T
915

1016
func None[T any]() Option[T] {

services/packages/cargo/index.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ func alterRepositoryContent(ctx context.Context, doer *user_model.User, repo *re
310310
}
311311

312312
func writeObjectToIndex(ctx context.Context, t *files_service.TemporaryUploadRepository, path string, r io.Reader) error {
313-
hash, err := t.HashObject(ctx, r)
313+
hash, err := t.HashObjectAndWrite(ctx, r)
314314
if err != nil {
315315
return err
316316
}

services/repository/files/diff.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func GetDiffPreview(ctx context.Context, repo *repo_model.Repository, branch, tr
2929
}
3030

3131
// Add the object to the database
32-
objectHash, err := t.HashObject(ctx, strings.NewReader(content))
32+
objectHash, err := t.HashObjectAndWrite(ctx, strings.NewReader(content))
3333
if err != nil {
3434
return nil, err
3535
}

services/repository/files/temp_repo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ func (t *TemporaryUploadRepository) RemoveFilesFromIndex(ctx context.Context, fi
164164
return nil
165165
}
166166

167-
// HashObject writes the provided content to the object db and returns its hash
168-
func (t *TemporaryUploadRepository) HashObject(ctx context.Context, content io.Reader) (string, error) {
167+
// HashObjectAndWrite writes the provided content to the object db and returns its hash
168+
func (t *TemporaryUploadRepository) HashObjectAndWrite(ctx context.Context, content io.Reader) (string, error) {
169169
stdOut := new(bytes.Buffer)
170170
stdErr := new(bytes.Buffer)
171171

0 commit comments

Comments
 (0)