0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-02-21 22:18:23 +01:00
This commit is contained in:
Lunny Xiao 2026-02-20 11:59:20 -08:00
parent 305795c6aa
commit e9222e4f63
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
3 changed files with 5 additions and 2 deletions

View File

@ -150,7 +150,7 @@ type CreateRepoOption struct {
DefaultBranch string `json:"default_branch" binding:"GitRefName;MaxSize(100)"`
// TrustModel of the repository
// enum: default,collaborator,committer,collaboratorcommitter
TrustModel string `json:"trust_model" binding:"In(default,collaborator,committer,collaboratorcommitter)"`
TrustModel string `json:"trust_model"`
// ObjectFormatName of the underlying git repository, empty string for default (sha1)
// enum: sha1,sha256
ObjectFormatName string `json:"object_format_name" binding:"MaxSize(6)"`

View File

@ -42,7 +42,7 @@ type CreateRepoForm struct {
ProtectedBranch bool
ForkSingleBranch string `binding:"MaxSize(255)"`
ObjectFormatName string `binding:"In(sha1,sha256)"`
ObjectFormatName string
}
// Validate validates the fields

View File

@ -230,6 +230,9 @@ func CreateRepositoryDirectly(ctx context.Context, doer, owner *user_model.User,
if opts.ObjectFormatName == "" {
opts.ObjectFormatName = git.Sha1ObjectFormat.Name()
}
if opts.ObjectFormatName != git.Sha1ObjectFormat.Name() && opts.ObjectFormatName != git.Sha256ObjectFormat.Name() {
return nil, fmt.Errorf("unsupported object format: %s", opts.ObjectFormatName)
}
repo := &repo_model.Repository{
OwnerID: owner.ID,