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:
@ -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{
|
||||
|
Reference in New Issue
Block a user