aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2020-11-10 19:44:45 +0800
committerGitHub <noreply@github.com>2020-11-10 13:44:45 +0200
commit542edc22c429fa5e79636067367ac40fb1820cb1 (patch)
tree52aee8e29ae6ac08896a64d364bd193bb2b53ecd /models
parentbeab1dd337250cdef4e4a7588a19e7d711eb870e (diff)
downloadgitea-542edc22c429fa5e79636067367ac40fb1820cb1.tar.gz
gitea-542edc22c429fa5e79636067367ac40fb1820cb1.zip
Some improvements for v156 (#13497)
Diffstat (limited to 'models')
-rw-r--r--models/migrations/v156.go19
1 files changed, 12 insertions, 7 deletions
diff --git a/models/migrations/v156.go b/models/migrations/v156.go
index d1770b6101..af37e67d82 100644
--- a/models/migrations/v156.go
+++ b/models/migrations/v156.go
@@ -55,6 +55,7 @@ func fixPublisherIDforTagReleases(x *xorm.Engine) error {
var (
repo *Repository
gitRepo *git.Repository
+ user *User
)
defer func() {
if gitRepo != nil {
@@ -69,7 +70,7 @@ func fixPublisherIDforTagReleases(x *xorm.Engine) error {
}
if err := sess.Limit(batchSize, start).
- Where("publisher_id = 0").
+ Where("publisher_id = 0 OR publisher_id is null").
Asc("repo_id", "id").Where("is_tag=?", true).
Find(&releases); err != nil {
return err
@@ -117,17 +118,21 @@ func fixPublisherIDforTagReleases(x *xorm.Engine) error {
return fmt.Errorf("GetTagCommit: %v", err)
}
- u := new(User)
- exists, err := sess.Where("email=?", commit.Author.Email).Get(u)
- if err != nil {
- return err
+ if user == nil || !strings.EqualFold(user.Email, commit.Author.Email) {
+ user = new(User)
+ _, err = sess.Where("email=?", commit.Author.Email).Get(user)
+ if err != nil {
+ return err
+ }
+
+ user.Email = commit.Author.Email
}
- if !exists {
+ if user.ID <= 0 {
continue
}
- release.PublisherID = u.ID
+ release.PublisherID = user.ID
if _, err := sess.ID(release.ID).Cols("publisher_id").Update(release); err != nil {
return err
}