diff options
author | Joe Chen <jc@unknwon.io> | 2023-02-04 12:22:37 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-04 12:22:37 +0800 |
commit | ed51686240ff84e3cc12be8bc4311c529d44faee (patch) | |
tree | e8cdbc9a2870d1143e81b2524626bfd04ea6d1c7 /internal/route/repo/commit.go | |
parent | cc4d4eacad6b6a92ebb3380715dcaee3bcc5fd41 (diff) |
refactor(db): migrate methods off `user.go` (#7333)
Diffstat (limited to 'internal/route/repo/commit.go')
-rw-r--r-- | internal/route/repo/commit.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/internal/route/repo/commit.go b/internal/route/repo/commit.go index 3e09bd06..da8c5e48 100644 --- a/internal/route/repo/commit.go +++ b/internal/route/repo/commit.go @@ -5,6 +5,7 @@ package repo import ( + gocontext "context" "path" "time" @@ -110,6 +111,13 @@ func FileHistory(c *context.Context) { renderCommits(c, c.Repo.TreePath) } +// tryGetUserByEmail returns a non-nil value if the email is corresponding to an +// existing user. +func tryGetUserByEmail(ctx gocontext.Context, email string) *db.User { + user, _ := db.Users.GetByEmail(ctx, email) + return user +} + func Diff(c *context.Context) { c.PageIs("Diff") c.RequireHighlightJS() @@ -156,7 +164,7 @@ func Diff(c *context.Context) { c.Data["IsImageFile"] = commit.IsImageFile c.Data["IsImageFileByIndex"] = commit.IsImageFileByIndex c.Data["Commit"] = commit - c.Data["Author"] = db.ValidateCommitWithEmail(commit) + c.Data["Author"] = tryGetUserByEmail(c.Req.Context(), commit.Author.Email) c.Data["Diff"] = diff c.Data["Parents"] = parents c.Data["DiffNotAvailable"] = diff.NumFiles() == 0 |