summaryrefslogtreecommitdiffstats
path: root/models/user/user.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/user/user.go')
-rw-r--r--models/user/user.go15
1 files changed, 5 insertions, 10 deletions
diff --git a/models/user/user.go b/models/user/user.go
index 0917bea754..0a43de7435 100644
--- a/models/user/user.go
+++ b/models/user/user.go
@@ -1114,11 +1114,11 @@ type UserCommit struct { //revive:disable-line:exported
}
// ValidateCommitWithEmail check if author's e-mail of commit is corresponding to a user.
-func ValidateCommitWithEmail(c *git.Commit) *User {
+func ValidateCommitWithEmail(ctx context.Context, c *git.Commit) *User {
if c.Author == nil {
return nil
}
- u, err := GetUserByEmail(c.Author.Email)
+ u, err := GetUserByEmail(ctx, c.Author.Email)
if err != nil {
return nil
}
@@ -1126,7 +1126,7 @@ func ValidateCommitWithEmail(c *git.Commit) *User {
}
// ValidateCommitsWithEmails checks if authors' e-mails of commits are corresponding to users.
-func ValidateCommitsWithEmails(oldCommits []*git.Commit) []*UserCommit {
+func ValidateCommitsWithEmails(ctx context.Context, oldCommits []*git.Commit) []*UserCommit {
var (
emails = make(map[string]*User)
newCommits = make([]*UserCommit, 0, len(oldCommits))
@@ -1135,7 +1135,7 @@ func ValidateCommitsWithEmails(oldCommits []*git.Commit) []*UserCommit {
var u *User
if c.Author != nil {
if v, ok := emails[c.Author.Email]; !ok {
- u, _ = GetUserByEmail(c.Author.Email)
+ u, _ = GetUserByEmail(ctx, c.Author.Email)
emails[c.Author.Email] = u
} else {
u = v
@@ -1151,12 +1151,7 @@ func ValidateCommitsWithEmails(oldCommits []*git.Commit) []*UserCommit {
}
// GetUserByEmail returns the user object by given e-mail if exists.
-func GetUserByEmail(email string) (*User, error) {
- return GetUserByEmailContext(db.DefaultContext, email)
-}
-
-// GetUserByEmailContext returns the user object by given e-mail if exists with db context
-func GetUserByEmailContext(ctx context.Context, email string) (*User, error) {
+func GetUserByEmail(ctx context.Context, email string) (*User, error) {
if len(email) == 0 {
return nil, ErrUserNotExist{0, email, 0}
}