MCPcopy Index your code
hub / github.com/gogs/gogs / matchUsersWithCommitEmails

Function matchUsersWithCommitEmails

internal/route/repo/commit.go:193–212  ·  view source on GitHub ↗

matchUsersWithCommitEmails matches existing users using commit author emails.

(ctx gocontext.Context, oldCommits []*git.Commit)

Source from the content-addressed store, hash-verified

191
192// matchUsersWithCommitEmails matches existing users using commit author emails.
193func matchUsersWithCommitEmails(ctx gocontext.Context, oldCommits []*git.Commit) []*userCommit {
194 emailToUsers := make(map[string]*database.User)
195 newCommits := make([]*userCommit, len(oldCommits))
196 usersStore := database.Handle.Users()
197 for i := range oldCommits {
198 var u *database.User
199 if v, ok := emailToUsers[oldCommits[i].Author.Email]; !ok {
200 u, _ = usersStore.GetByEmail(ctx, oldCommits[i].Author.Email)
201 emailToUsers[oldCommits[i].Author.Email] = u
202 } else {
203 u = v
204 }
205
206 newCommits[i] = &userCommit{
207 User: u,
208 Commit: oldCommits[i],
209 }
210 }
211 return newCommits
212}
213
214func CompareDiff(c *context.Context) {
215 c.Data["IsDiffCompare"] = true

Callers 5

ViewPullCommitsFunction · 0.85
PrepareCompareDiffFunction · 0.85
renderCommitsFunction · 0.85
SearchCommitsFunction · 0.85
CompareDiffFunction · 0.85

Calls 2

UsersMethod · 0.80
GetByEmailMethod · 0.80

Tested by

no test coverage detected