summaryrefslogtreecommitdiffstats
path: root/models/user.go
diff options
context:
space:
mode:
authorUnknwon <joe2010xtmf@163.com>2014-09-23 15:30:04 -0400
committerUnknwon <joe2010xtmf@163.com>2014-09-23 15:30:04 -0400
commit5bbeeb0f1b5cecb67e1527410a45fb65df0096d1 (patch)
tree7c135abd7c84f4e1743ad621265fbaee25bf5f99 /models/user.go
parent93ee0838eb317ce729391fbfafa0595f561e3f65 (diff)
downloadgitea-5bbeeb0f1b5cecb67e1527410a45fb65df0096d1.tar.gz
gitea-5bbeeb0f1b5cecb67e1527410a45fb65df0096d1.zip
Page: Commits and fix #249
Diffstat (limited to 'models/user.go')
-rw-r--r--models/user.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/models/user.go b/models/user.go
index 46e1b1554b..c09a77265f 100644
--- a/models/user.go
+++ b/models/user.go
@@ -5,6 +5,7 @@
package models
import (
+ "container/list"
"crypto/sha256"
"encoding/hex"
"errors"
@@ -513,6 +514,34 @@ func GetUserIdsByNames(names []string) []int64 {
return ids
}
+// UserCommit represtns a commit with validation of user.
+type UserCommit struct {
+ UserName string
+ *git.Commit
+}
+
+// ValidCommitsWithEmails checks if authors' e-mails of commits are correcponding to users.
+func ValidCommitsWithEmails(oldCommits *list.List) *list.List {
+ newCommits := list.New()
+ e := oldCommits.Front()
+ for e != nil {
+ c := e.Value.(*git.Commit)
+
+ uname := ""
+ u, err := GetUserByEmail(c.Author.Email)
+ if err == nil {
+ uname = u.Name
+ }
+
+ newCommits.PushBack(UserCommit{
+ UserName: uname,
+ Commit: c,
+ })
+ e = e.Next()
+ }
+ return newCommits
+}
+
// GetUserByEmail returns the user object by given e-mail if exists.
func GetUserByEmail(email string) (*User, error) {
if len(email) == 0 {