|
|
@@ -15,6 +15,7 @@ import ( |
|
|
|
"net/url" |
|
|
|
"path" |
|
|
|
"strings" |
|
|
|
"time" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/models" |
|
|
|
"code.gitea.io/gitea/modules/base" |
|
|
@@ -588,39 +589,45 @@ func Home(ctx *context.Context) { |
|
|
|
//get repo contributors info |
|
|
|
contributors, err := git.GetContributors(ctx.Repo.Repository.RepoPath()) |
|
|
|
if err == nil && contributors != nil { |
|
|
|
startTime := time.Now() |
|
|
|
var contributorInfos []*ContributorInfo |
|
|
|
contributorInfoHash:= make(map[string]*ContributorInfo) |
|
|
|
for _, c := range contributors { |
|
|
|
if strings.Compare(c.Email,"") == 0 { |
|
|
|
continue |
|
|
|
} |
|
|
|
// get user info from committer email |
|
|
|
user, err := models.GetUserByEmail(c.Email) |
|
|
|
user, err := models.GetUserByActivateEmail(c.Email) |
|
|
|
if err == nil { |
|
|
|
// committer is system user, get info through user's primary email |
|
|
|
existedContributorInfo := getContributorInfo(contributorInfos,user.Email) |
|
|
|
if existedContributorInfo != nil { |
|
|
|
if existedContributorInfo,ok:=contributorInfoHash[user.Email];ok { |
|
|
|
// existed: same primary email, different committer name |
|
|
|
existedContributorInfo.CommitCnt += c.CommitCnt |
|
|
|
}else{ |
|
|
|
// new committer info |
|
|
|
contributorInfos = append(contributorInfos, &ContributorInfo{ |
|
|
|
var newContributor = &ContributorInfo{ |
|
|
|
user, user.Email,c.CommitCnt, |
|
|
|
}) |
|
|
|
} |
|
|
|
contributorInfos = append(contributorInfos, newContributor ) |
|
|
|
contributorInfoHash[user.Email] = newContributor |
|
|
|
} |
|
|
|
} else { |
|
|
|
// committer is not system user |
|
|
|
existedContributorInfo := getContributorInfo(contributorInfos,c.Email) |
|
|
|
if existedContributorInfo != nil { |
|
|
|
if existedContributorInfo,ok:=contributorInfoHash[c.Email];ok { |
|
|
|
// existed: same primary email, different committer name |
|
|
|
existedContributorInfo.CommitCnt += c.CommitCnt |
|
|
|
}else{ |
|
|
|
contributorInfos = append(contributorInfos, &ContributorInfo{ |
|
|
|
nil, c.Email,c.CommitCnt, |
|
|
|
}) |
|
|
|
var newContributor = &ContributorInfo{ |
|
|
|
user, c.Email,c.CommitCnt, |
|
|
|
} |
|
|
|
contributorInfos = append(contributorInfos, newContributor) |
|
|
|
contributorInfoHash[c.Email] = newContributor |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.Data["ContributorInfo"] = contributorInfos |
|
|
|
var duration = time.Since(startTime) |
|
|
|
log.Info("getContributorInfo cost: %v seconds",duration.Seconds()) |
|
|
|
} |
|
|
|
if ctx.Repo.Repository.IsBeingCreated() { |
|
|
|
task, err := models.GetMigratingTask(ctx.Repo.Repository.ID) |
|
|
|