code.gitea.io/gitea@v1.21.7/services/convert/utils.go (about) 1 // Copyright 2020 The Gitea Authors. All rights reserved. 2 // Copyright 2016 The Gogs Authors. All rights reserved. 3 // SPDX-License-Identifier: MIT 4 5 package convert 6 7 import ( 8 "strings" 9 10 "code.gitea.io/gitea/modules/setting" 11 "code.gitea.io/gitea/modules/structs" 12 ) 13 14 // ToCorrectPageSize makes sure page size is in allowed range. 15 func ToCorrectPageSize(size int) int { 16 if size <= 0 { 17 size = setting.API.DefaultPagingNum 18 } else if size > setting.API.MaxResponseItems { 19 size = setting.API.MaxResponseItems 20 } 21 return size 22 } 23 24 // ToGitServiceType return GitServiceType based on string 25 func ToGitServiceType(value string) structs.GitServiceType { 26 switch strings.ToLower(value) { 27 case "github": 28 return structs.GithubService 29 case "gitea": 30 return structs.GiteaService 31 case "gitlab": 32 return structs.GitlabService 33 case "gogs": 34 return structs.GogsService 35 case "onedev": 36 return structs.OneDevService 37 case "gitbucket": 38 return structs.GitBucketService 39 default: 40 return structs.PlainGitService 41 } 42 }