2020-09-11 03:59:19 +05:30
|
|
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
2016-07-04 14:57:06 +05:30
|
|
|
// Copyright 2016 The Gogs Authors. All rights reserved.
|
2022-11-27 23:50:29 +05:30
|
|
|
// SPDX-License-Identifier: MIT
|
2016-07-04 14:57:06 +05:30
|
|
|
|
|
|
|
package convert
|
|
|
|
|
|
|
|
import (
|
2020-09-11 03:59:19 +05:30
|
|
|
"strings"
|
|
|
|
|
2016-11-10 21:54:48 +05:30
|
|
|
"code.gitea.io/gitea/modules/setting"
|
2020-09-11 03:59:19 +05:30
|
|
|
"code.gitea.io/gitea/modules/structs"
|
2016-07-04 14:57:06 +05:30
|
|
|
)
|
|
|
|
|
|
|
|
// ToCorrectPageSize makes sure page size is in allowed range.
|
|
|
|
func ToCorrectPageSize(size int) int {
|
|
|
|
if size <= 0 {
|
2020-06-09 08:16:51 +05:30
|
|
|
size = setting.API.DefaultPagingNum
|
2016-07-04 14:57:06 +05:30
|
|
|
} else if size > setting.API.MaxResponseItems {
|
|
|
|
size = setting.API.MaxResponseItems
|
|
|
|
}
|
|
|
|
return size
|
|
|
|
}
|
2020-09-11 03:59:19 +05:30
|
|
|
|
|
|
|
// ToGitServiceType return GitServiceType based on string
|
|
|
|
func ToGitServiceType(value string) structs.GitServiceType {
|
|
|
|
switch strings.ToLower(value) {
|
|
|
|
case "github":
|
|
|
|
return structs.GithubService
|
|
|
|
case "gitea":
|
|
|
|
return structs.GiteaService
|
|
|
|
case "gitlab":
|
|
|
|
return structs.GitlabService
|
|
|
|
case "gogs":
|
|
|
|
return structs.GogsService
|
2021-08-22 04:17:45 +05:30
|
|
|
case "onedev":
|
|
|
|
return structs.OneDevService
|
2021-11-15 00:41:10 +05:30
|
|
|
case "gitbucket":
|
|
|
|
return structs.GitBucketService
|
2023-12-05 21:13:35 +05:30
|
|
|
case "forgejo":
|
|
|
|
return structs.ForgejoService
|
2020-09-11 03:59:19 +05:30
|
|
|
default:
|
|
|
|
return structs.PlainGitService
|
|
|
|
}
|
|
|
|
}
|