summaryrefslogtreecommitdiffstats
path: root/models/user.go
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2021-08-09 20:08:51 +0200
committerGitHub <noreply@github.com>2021-08-09 14:08:51 -0400
commitd9ef43a7126ab83af563c1c9b54cdf0092327b2a (patch)
treefabc9a9d24d42bb0de6dd9557c9e07e95bd5722b /models/user.go
parent23d438f56524a7c3fc185df66d6d95f797a80eee (diff)
downloadgitea-d9ef43a7126ab83af563c1c9b54cdf0092327b2a.tar.gz
gitea-d9ef43a7126ab83af563c1c9b54cdf0092327b2a.zip
Replace `list.List` with slices (#16311)
* Replaced list with slice. * Fixed usage of pointer to temporary variable. * Replaced LIFO list with slice. * Lint * Removed type check. * Removed duplicated code. * Lint * Fixed merge. Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'models/user.go')
-rw-r--r--models/user.go19
1 files changed, 6 insertions, 13 deletions
diff --git a/models/user.go b/models/user.go
index a4f94999ee..c68417a2c3 100644
--- a/models/user.go
+++ b/models/user.go
@@ -6,7 +6,6 @@
package models
import (
- "container/list"
"context"
"crypto/sha256"
"crypto/subtle"
@@ -1509,16 +1508,13 @@ func ValidateCommitWithEmail(c *git.Commit) *User {
}
// ValidateCommitsWithEmails checks if authors' e-mails of commits are corresponding to users.
-func ValidateCommitsWithEmails(oldCommits *list.List) *list.List {
+func ValidateCommitsWithEmails(oldCommits []*git.Commit) []*UserCommit {
var (
- u *User
- emails = map[string]*User{}
- newCommits = list.New()
- e = oldCommits.Front()
+ emails = make(map[string]*User)
+ newCommits = make([]*UserCommit, 0, len(oldCommits))
)
- for e != nil {
- c := e.Value.(*git.Commit)
-
+ for _, c := range oldCommits {
+ var u *User
if c.Author != nil {
if v, ok := emails[c.Author.Email]; !ok {
u, _ = GetUserByEmail(c.Author.Email)
@@ -1526,15 +1522,12 @@ func ValidateCommitsWithEmails(oldCommits *list.List) *list.List {
} else {
u = v
}
- } else {
- u = nil
}
- newCommits.PushBack(UserCommit{
+ newCommits = append(newCommits, &UserCommit{
User: u,
Commit: c,
})
- e = e.Next()
}
return newCommits
}