diff options
author | Lauris BH <lauris@nix.lv> | 2017-10-26 10:45:14 +0300 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-10-26 15:45:14 +0800 |
commit | 6a107e57f6ded230b9e9f6861ac2101a34f260b1 (patch) | |
tree | 5536ed9ec4b0a847f3a0caa8a906c19cc9f7c983 /models/user.go | |
parent | bc8411098979da5599d314e982da2985e0bb29c2 (diff) | |
download | gitea-6a107e57f6ded230b9e9f6861ac2101a34f260b1.tar.gz gitea-6a107e57f6ded230b9e9f6861ac2101a34f260b1.zip |
Add checks for commits with missing author and time (#2771)
* Add checks for commits with missing author and time
* Fix validate commits with emails if it has no Author
Diffstat (limited to 'models/user.go')
-rw-r--r-- | models/user.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/models/user.go b/models/user.go index 337c39efe4..4dd2ad8d89 100644 --- a/models/user.go +++ b/models/user.go @@ -1193,6 +1193,9 @@ type UserCommit struct { // ValidateCommitWithEmail check if author's e-mail of commit is corresponding to a user. func ValidateCommitWithEmail(c *git.Commit) *User { + if c.Author == nil { + return nil + } u, err := GetUserByEmail(c.Author.Email) if err != nil { return nil @@ -1211,11 +1214,15 @@ func ValidateCommitsWithEmails(oldCommits *list.List) *list.List { for e != nil { c := e.Value.(*git.Commit) - if v, ok := emails[c.Author.Email]; !ok { - u, _ = GetUserByEmail(c.Author.Email) - emails[c.Author.Email] = u + if c.Author != nil { + if v, ok := emails[c.Author.Email]; !ok { + u, _ = GetUserByEmail(c.Author.Email) + emails[c.Author.Email] = u + } else { + u = v + } } else { - u = v + u = nil } newCommits.PushBack(UserCommit{ |