mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-20 14:00:04 +02:00
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:
parent
23d438f565
commit
d9ef43a712
29 changed files with 183 additions and 302 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue