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>
This commit is contained in:
KN4CK3R 2021-08-09 20:08:51 +02:00 committed by GitHub
parent 23d438f565
commit d9ef43a712
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 183 additions and 302 deletions

View file

@ -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
}