Add validation constraints for repository creation fields (#36671)

Adds validation constraints to repository creation inputs, enforcing
max-length limits for labels/license/readme and enum validation for
trust model and object format. Updates both the API option struct and
the web form struct to keep validation consistent.
This commit is contained in:
Lunny Xiao
2026-02-25 08:28:39 -08:00
committed by GitHub
parent 577ed107dd
commit 569c49debe
4 changed files with 12 additions and 9 deletions
+3
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,