summaryrefslogtreecommitdiffstats
path: root/modules/convert
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-09-11 00:29:19 +0200
committerGitHub <noreply@github.com>2020-09-10 23:29:19 +0100
commitfd60ebfe14927657ff5cfa4e75f975eaadae65f1 (patch)
tree38c3d70146920a13c228fed91bc1a55c9be72436 /modules/convert
parentdaefdd1385d12bf0c8321f291dbb6ab242b41c99 (diff)
downloadgitea-fd60ebfe14927657ff5cfa4e75f975eaadae65f1.tar.gz
gitea-fd60ebfe14927657ff5cfa4e75f975eaadae65f1.zip
[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
Diffstat (limited to 'modules/convert')
-rw-r--r--modules/convert/utils.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/modules/convert/utils.go b/modules/convert/utils.go
index ddb8a8820d..69de306689 100644
--- a/modules/convert/utils.go
+++ b/modules/convert/utils.go
@@ -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
+ }
+}