1
0
Fork 0
forked from forgejo/forgejo

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

@ -5,7 +5,6 @@
package models
import (
"container/list"
"fmt"
"hash"
"strings"
@ -68,24 +67,19 @@ const (
)
// ParseCommitsWithSignature checks if signaute of commits are corresponding to users gpg keys.
func ParseCommitsWithSignature(oldCommits *list.List, repository *Repository) *list.List {
var (
newCommits = list.New()
e = oldCommits.Front()
)
func ParseCommitsWithSignature(oldCommits []*UserCommit, repository *Repository) []*SignCommit {
newCommits := make([]*SignCommit, 0, len(oldCommits))
keyMap := map[string]bool{}
for e != nil {
c := e.Value.(UserCommit)
signCommit := SignCommit{
UserCommit: &c,
for _, c := range oldCommits {
signCommit := &SignCommit{
UserCommit: c,
Verification: ParseCommitWithSignature(c.Commit),
}
_ = CalculateTrustStatus(signCommit.Verification, repository, &keyMap)
newCommits.PushBack(signCommit)
e = e.Next()
newCommits = append(newCommits, signCommit)
}
return newCommits
}