|
|
@@ -6,13 +6,6 @@ package repo |
|
|
|
|
|
|
|
import ( |
|
|
|
"bytes" |
|
|
|
"container/list" |
|
|
|
"fmt" |
|
|
|
"html" |
|
|
|
gotemplate "html/template" |
|
|
|
"net/url" |
|
|
|
"strings" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/models" |
|
|
|
"code.gitea.io/gitea/modules/base" |
|
|
|
"code.gitea.io/gitea/modules/context" |
|
|
@@ -22,6 +15,12 @@ import ( |
|
|
|
"code.gitea.io/gitea/modules/markup" |
|
|
|
"code.gitea.io/gitea/modules/setting" |
|
|
|
"code.gitea.io/gitea/modules/timeutil" |
|
|
|
"container/list" |
|
|
|
"fmt" |
|
|
|
"html" |
|
|
|
gotemplate "html/template" |
|
|
|
"net/url" |
|
|
|
"strings" |
|
|
|
) |
|
|
|
|
|
|
|
const ( |
|
|
@@ -35,7 +34,52 @@ func RefBlame(ctx *context.Context) { |
|
|
|
ctx.NotFound("Blame FileName", nil) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
//get repo contributors info |
|
|
|
contributors, err := git.GetContributors(ctx.Repo.Repository.RepoPath(), ctx.Repo.BranchName) |
|
|
|
if err == nil && contributors != nil { |
|
|
|
var contributorInfos []*ContributorInfo |
|
|
|
contributorInfoHash := make(map[string]*ContributorInfo) |
|
|
|
count := 0 |
|
|
|
for _, c := range contributors { |
|
|
|
if count >= 25 { |
|
|
|
continue |
|
|
|
} |
|
|
|
if strings.Compare(c.Email, "") == 0 { |
|
|
|
continue |
|
|
|
} |
|
|
|
// get user info from committer email |
|
|
|
user, err := models.GetUserByActivateEmail(c.Email) |
|
|
|
if err == nil { |
|
|
|
// committer is system user, get info through user's primary email |
|
|
|
if existedContributorInfo, ok := contributorInfoHash[user.Email]; ok { |
|
|
|
// existed: same primary email, different committer name |
|
|
|
existedContributorInfo.CommitCnt += c.CommitCnt |
|
|
|
} else { |
|
|
|
// new committer info |
|
|
|
var newContributor = &ContributorInfo{ |
|
|
|
user, user.RelAvatarLink(), user.Name, user.Email, c.CommitCnt, |
|
|
|
} |
|
|
|
count++ |
|
|
|
contributorInfos = append(contributorInfos, newContributor) |
|
|
|
contributorInfoHash[user.Email] = newContributor |
|
|
|
} |
|
|
|
} else { |
|
|
|
// committer is not system user |
|
|
|
if existedContributorInfo, ok := contributorInfoHash[c.Email]; ok { |
|
|
|
// existed: same primary email, different committer name |
|
|
|
existedContributorInfo.CommitCnt += c.CommitCnt |
|
|
|
} else { |
|
|
|
var newContributor = &ContributorInfo{ |
|
|
|
user, "", "", c.Email, c.CommitCnt, |
|
|
|
} |
|
|
|
count++ |
|
|
|
contributorInfos = append(contributorInfos, newContributor) |
|
|
|
contributorInfoHash[c.Email] = newContributor |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.Data["ContributorInfo"] = contributorInfos |
|
|
|
} |
|
|
|
userName := ctx.Repo.Owner.Name |
|
|
|
repoName := ctx.Repo.Repository.Name |
|
|
|
commitID := ctx.Repo.CommitID |
|
|
|