forked from forgejo/forgejo
[API] Migration: Change ServiceType String (#12672)
* use different structs for MigrateRepoOptions on UI and API * Fix TokenAuth and rename UID to an understandable Name * fix swagger doc * simplify & mk redable * R E F A C T O R: migration has now internal 3 structs to store its options: * the Options for WebUI: modules/auth/repo_form.go * the Options for API: modules/structs/repo.go * the option struct with after validation for internal prossessing: modules/migrations/base/options.go * Copyright Header * Deprecate UID - add RepoOwner * adopt repo.go -> migrate.go * add comment about each struct purpose * lint
This commit is contained in:
parent
daefdd1385
commit
fd60ebfe14
16 changed files with 230 additions and 87 deletions
|
@ -1,3 +1,4 @@
|
|||
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||||
// Copyright 2016 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
@ -5,7 +6,10 @@
|
|||
package convert
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/structs"
|
||||
)
|
||||
|
||||
// ToCorrectPageSize makes sure page size is in allowed range.
|
||||
|
@ -17,3 +21,19 @@ func ToCorrectPageSize(size int) int {
|
|||
}
|
||||
return size
|
||||
}
|
||||
|
||||
// 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
|
||||
default:
|
||||
return structs.PlainGitService
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue