|
|
@@ -569,10 +569,19 @@ func safeURL(address string) string { |
|
|
|
} |
|
|
|
|
|
|
|
type ContributorInfo struct { |
|
|
|
UserInfo *models.User |
|
|
|
Email string // for contributor who is not a registered user |
|
|
|
UserInfo *models.User // nil for contributor who is not a registered user |
|
|
|
Email string |
|
|
|
CommitCnt int |
|
|
|
} |
|
|
|
|
|
|
|
func getContributorInfo(contributorInfos []*ContributorInfo, email string) *ContributorInfo{ |
|
|
|
for _, c := range contributorInfos { |
|
|
|
if strings.Compare(c.Email,email) == 0 { |
|
|
|
return c |
|
|
|
} |
|
|
|
} |
|
|
|
return nil |
|
|
|
} |
|
|
|
// Home render repository home page |
|
|
|
func Home(ctx *context.Context) { |
|
|
|
if len(ctx.Repo.Units) > 0 { |
|
|
@@ -583,12 +592,17 @@ func Home(ctx *context.Context) { |
|
|
|
for _, c := range contributors { |
|
|
|
user, err := models.GetUserByEmail(c.Email) |
|
|
|
if err == nil { |
|
|
|
contributorInfos = append(contributorInfos, &ContributorInfo{ |
|
|
|
user, c.Email, |
|
|
|
}) |
|
|
|
existedContributorInfo := getContributorInfo(contributorInfos,user.Email) |
|
|
|
if existedContributorInfo != nil { |
|
|
|
existedContributorInfo.CommitCnt += c.CommitCnt |
|
|
|
}else{ |
|
|
|
contributorInfos = append(contributorInfos, &ContributorInfo{ |
|
|
|
user, user.Email,c.CommitCnt, |
|
|
|
}) |
|
|
|
} |
|
|
|
} else { |
|
|
|
contributorInfos = append(contributorInfos, &ContributorInfo{ |
|
|
|
nil, c.Email, |
|
|
|
nil, c.Email,c.CommitCnt, |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|