summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-03-01 23:05:44 +0100
committerGitHub <noreply@github.com>2020-03-02 00:05:44 +0200
commit4160bd6ef1e70f3e6ec6bb69b1cd37a66f14c4e3 (patch)
tree104077af60eb5e8d756da5d0c7a12f6e19ef3133 /modules
parentc08c975d368771237d6509df915d3ec315186612 (diff)
downloadgitea-4160bd6ef1e70f3e6ec6bb69b1cd37a66f14c4e3.tar.gz
gitea-4160bd6ef1e70f3e6ec6bb69b1cd37a66f14c4e3.zip
Remove Unused Functions (#10516)
* remove ReplaceLeft * remove GetRepositoryByOwnerAndName chainload to models.GetRepositoryByOwnerAndName * remove CheckUnitUser chainload to models.CheckUnitUser * remove MakeAssigneeList * remove DownloadDiff & DownloadPatch -> DownloadDiffOrPatch * remove GetRandomBytesAsBase64 * remove PushUpdateDeleteTags * remove GetUserByKeyID (you still can resolve user by "k, err := GetPublicKeyByID; userID := k.OwnerID") * remove BasicAuthEncode from struct package -> same function in modules/base/tools ! * remove UserID from api.utils * remove unused func from structs package
Diffstat (limited to 'modules')
-rw-r--r--modules/base/tool.go14
-rw-r--r--modules/structs/user_app.go6
-rw-r--r--modules/structs/utils.go20
-rw-r--r--modules/templates/helper.go25
4 files changed, 0 insertions, 65 deletions
diff --git a/modules/base/tool.go b/modules/base/tool.go
index cb9b996142..86606c8bee 100644
--- a/modules/base/tool.go
+++ b/modules/base/tool.go
@@ -6,13 +6,11 @@ package base
import (
"crypto/md5"
- "crypto/rand"
"crypto/sha1"
"crypto/sha256"
"encoding/base64"
"encoding/hex"
"fmt"
- "io"
"net/http"
"net/url"
"os"
@@ -75,18 +73,6 @@ func BasicAuthEncode(username, password string) string {
return base64.StdEncoding.EncodeToString([]byte(username + ":" + password))
}
-// GetRandomBytesAsBase64 generates a random base64 string from n bytes
-func GetRandomBytesAsBase64(n int) string {
- bytes := make([]byte, 32)
- _, err := io.ReadFull(rand.Reader, bytes)
-
- if err != nil {
- log.Fatal("Error reading random bytes: %v", err)
- }
-
- return base64.RawURLEncoding.EncodeToString(bytes)
-}
-
// VerifyTimeLimitCode verify time limit code
func VerifyTimeLimitCode(data string, minutes int, code string) bool {
if len(code) <= 18 {
diff --git a/modules/structs/user_app.go b/modules/structs/user_app.go
index a0b0c3cb70..44df5a6a49 100644
--- a/modules/structs/user_app.go
+++ b/modules/structs/user_app.go
@@ -6,15 +6,9 @@
package structs
import (
- "encoding/base64"
"time"
)
-// BasicAuthEncode generate base64 of basic auth head
-func BasicAuthEncode(user, pass string) string {
- return base64.StdEncoding.EncodeToString([]byte(user + ":" + pass))
-}
-
// AccessToken represents an API access token.
// swagger:response AccessToken
type AccessToken struct {
diff --git a/modules/structs/utils.go b/modules/structs/utils.go
deleted file mode 100644
index aaeb653d03..0000000000
--- a/modules/structs/utils.go
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2015 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.
-
-package structs
-
-// Bool return address of bool value
-func Bool(v bool) *bool {
- return &v
-}
-
-// String return address of string value
-func String(v string) *string {
- return &v
-}
-
-// Int64 return address of int64 value
-func Int64(v int64) *int64 {
- return &v
-}
diff --git a/modules/templates/helper.go b/modules/templates/helper.go
index a97431a69e..9d3206934e 100644
--- a/modules/templates/helper.go
+++ b/modules/templates/helper.go
@@ -437,31 +437,6 @@ func Sha1(str string) string {
return base.EncodeSha1(str)
}
-// ReplaceLeft replaces all prefixes 'oldS' in 's' with 'newS'.
-func ReplaceLeft(s, oldS, newS string) string {
- oldLen, newLen, i, n := len(oldS), len(newS), 0, 0
- for ; i < len(s) && strings.HasPrefix(s[i:], oldS); n++ {
- i += oldLen
- }
-
- // simple optimization
- if n == 0 {
- return s
- }
-
- // allocating space for the new string
- curLen := n*newLen + len(s[i:])
- replacement := make([]byte, curLen)
-
- j := 0
- for ; j < n*newLen; j += newLen {
- copy(replacement[j:j+newLen], newS)
- }
-
- copy(replacement[j:], s[i:])
- return string(replacement)
-}
-
// RenderCommitMessage renders commit message with XSS-safe and special links.
func RenderCommitMessage(msg, urlPrefix string, metas map[string]string) template.HTML {
return RenderCommitMessageLink(msg, urlPrefix, "", metas)