From aa6d260ca121d18b4b31b5647d708ce41bf3beb6 Mon Sep 17 00:00:00 2001 From: Artur Galyamov Date: Mon, 7 Nov 2022 15:10:48 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=81=D1=82=D0=BE=D0=BB=D0=B1=D1=86?= =?UTF-8?q?=D0=BE=D0=B2=20=D0=B2=20=D0=BF=D0=BE=D0=BB=D1=8F=20=D1=81=D1=82?= =?UTF-8?q?=D1=80=D1=83=D0=BA=D1=82=D1=83=D1=80=D1=8B=20=D0=B4=D0=BE=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D0=B8=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D1=85=20?= =?UTF-8?q?=D1=81=D0=B2=D0=BE=D0=B9=D1=81=D1=82=D0=B2=20=D1=81=D0=B4=D0=B5?= =?UTF-8?q?=D0=BB=D0=B0=D0=BD=D0=BE=20=D0=B1=D0=BE=D0=BB=D0=B5=D0=B5=20?= =?UTF-8?q?=D1=8F=D0=B2=D0=BD=D0=BE=20#128?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/trust_props/trust_props.go | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/services/trust_props/trust_props.go b/services/trust_props/trust_props.go index 9f635f4b97..c7317c86ac 100644 --- a/services/trust_props/trust_props.go +++ b/services/trust_props/trust_props.go @@ -7,7 +7,6 @@ import ( "code.gitea.io/gitea/modules/markup/markdown" "reflect" "regexp" - "strings" ) func SaveRepoAndRenderContent(ctx *context.Context, colName string) (string, error) { @@ -28,7 +27,13 @@ func SaveRepoAndRenderContent(ctx *context.Context, colName string) (string, err if err != nil { return "", err } - fieldName := upCase(colName) + + fieldNames := map[string]string{ + "resources": "Resources", + "competences": "Competences", + } + + fieldName := fieldNames[colName] reflectedRepo := reflect.ValueOf(repo) reflectedRepo.Elem().FieldByName(fieldName).SetString(trimmedToggledContent) err = repo_model.UpdateRepositoryCols(repo, colName) @@ -40,19 +45,10 @@ func SaveRepoAndRenderContent(ctx *context.Context, colName string) (string, err } func trimSearchLinks(content string) (string, error) { - regExp, err := regexp.Compile(`\s*\[найти\]\(.+\s*\)`) + regExp, err := regexp.Compile(`\s+\[найти\]\(.+\s*\)`) if err != nil { return "", err } trimmedSearchLink := regExp.ReplaceAllString(content, "") return trimmedSearchLink, nil } - -func upCase(str string) string { - ch := rune(str[0]) - ch -= 'a' - 'A' - var upCasedSB strings.Builder - upCasedSB.WriteRune(ch) - upCasedSB.WriteString(str[1:]) - return upCasedSB.String() -}