mirror of https://github.com/go-gitea/gitea
Git with a cup of tea, painless self-hosted git service
Mirror for internal git.with.parts use
https://git.with.parts
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1011 B
43 lines
1011 B
4 years ago
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||
9 years ago
|
// Copyright 2016 The Gogs Authors. All rights reserved.
|
||
2 years ago
|
// SPDX-License-Identifier: MIT
|
||
9 years ago
|
|
||
|
package convert
|
||
|
|
||
|
import (
|
||
4 years ago
|
"strings"
|
||
|
|
||
8 years ago
|
"code.gitea.io/gitea/modules/setting"
|
||
4 years ago
|
"code.gitea.io/gitea/modules/structs"
|
||
9 years ago
|
)
|
||
|
|
||
|
// ToCorrectPageSize makes sure page size is in allowed range.
|
||
|
func ToCorrectPageSize(size int) int {
|
||
|
if size <= 0 {
|
||
5 years ago
|
size = setting.API.DefaultPagingNum
|
||
9 years ago
|
} else if size > setting.API.MaxResponseItems {
|
||
|
size = setting.API.MaxResponseItems
|
||
|
}
|
||
|
return size
|
||
|
}
|
||
4 years ago
|
|
||
|
// 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
|
||
3 years ago
|
case "onedev":
|
||
|
return structs.OneDevService
|
||
3 years ago
|
case "gitbucket":
|
||
|
return structs.GitBucketService
|
||
4 years ago
|
default:
|
||
|
return structs.PlainGitService
|
||
|
}
|
||
|
}
|