From fd60ebfe14927657ff5cfa4e75f975eaadae65f1 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Fri, 11 Sep 2020 00:29:19 +0200 Subject: [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 --- modules/convert/utils.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'modules/convert') 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 + } +} -- cgit v1.2.3