Skip to content

Commit

Permalink
Merge remote-tracking branch 'giteaofficial/main'
Browse files Browse the repository at this point in the history
* giteaofficial/main:
  Fix bug for get user by email (go-gitea#18833)
  migrations: remove dead code in gitea uploader (go-gitea#18725)
  • Loading branch information
zjjhot committed Feb 22, 2022
2 parents 33db79e + dc988ea commit a5156b2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 25 deletions.
14 changes: 2 additions & 12 deletions models/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -1117,19 +1117,9 @@ func GetUserByEmailContext(ctx context.Context, email string) (*User, error) {
}

email = strings.ToLower(email)
// First try to find the user by primary email
user := &User{Email: email}
has, err := db.GetEngine(ctx).Get(user)
if err != nil {
return nil, err
}
if has {
return user, nil
}

// Otherwise, check in alternative list for activated email addresses
emailAddress := &EmailAddress{Email: email, IsActivated: true}
has, err = db.GetEngine(ctx).Get(emailAddress)
emailAddress := &EmailAddress{LowerEmail: email, IsActivated: true}
has, err := db.GetEngine(ctx).Get(emailAddress)
if err != nil {
return nil, err
}
Expand Down
16 changes: 3 additions & 13 deletions services/migrations/gitea_uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,7 @@ func (g *GiteaLocalUploader) CreateComments(comments ...*base.Comment) error {
var issue *models.Issue
issue, ok := g.issues[comment.IssueIndex]
if !ok {
var err error
issue, err = models.GetIssueByIndex(g.repo.ID, comment.IssueIndex)
if err != nil {
return err
}
g.issues[comment.IssueIndex] = issue
return fmt.Errorf("comment references non existent IssueIndex %d", comment.IssueIndex)
}

if comment.Created.IsZero() {
Expand Down Expand Up @@ -685,19 +680,14 @@ func convertReviewState(state string) models.ReviewType {
}
}

// CreateReviews create pull request reviews
// CreateReviews create pull request reviews of currently migrated issues
func (g *GiteaLocalUploader) CreateReviews(reviews ...*base.Review) error {
cms := make([]*models.Review, 0, len(reviews))
for _, review := range reviews {
var issue *models.Issue
issue, ok := g.issues[review.IssueIndex]
if !ok {
var err error
issue, err = models.GetIssueByIndex(g.repo.ID, review.IssueIndex)
if err != nil {
return err
}
g.issues[review.IssueIndex] = issue
return fmt.Errorf("review references non existent IssueIndex %d", review.IssueIndex)
}
if review.CreatedAt.IsZero() {
review.CreatedAt = time.Unix(int64(issue.CreatedUnix), 0)
Expand Down

0 comments on commit a5156b2

Please sign in to comment.