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
This commit is contained in:
Lauris BH
2017-10-26 10:45:14 +03:00
committed by Lunny Xiao
parent bc84110989
commit 6a107e57f6
3 changed files with 43 additions and 18 deletions

View File

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