diff options
Diffstat (limited to 'models/update.go')
-rw-r--r-- | models/update.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/models/update.go b/models/update.go index 421c44bb40..0fb73ac891 100644 --- a/models/update.go +++ b/models/update.go @@ -7,14 +7,16 @@ package models import ( "fmt" "strings" + + "code.gitea.io/gitea/models/db" ) // PushUpdateDeleteTagsContext updates a number of delete tags with context -func PushUpdateDeleteTagsContext(ctx DBContext, repo *Repository, tags []string) error { - return pushUpdateDeleteTags(ctx.e, repo, tags) +func PushUpdateDeleteTagsContext(ctx *db.Context, repo *Repository, tags []string) error { + return pushUpdateDeleteTags(ctx.Engine(), repo, tags) } -func pushUpdateDeleteTags(e Engine, repo *Repository, tags []string) error { +func pushUpdateDeleteTags(e db.Engine, repo *Repository, tags []string) error { if len(tags) == 0 { return nil } @@ -53,14 +55,14 @@ func PushUpdateDeleteTag(repo *Repository, tagName string) error { return fmt.Errorf("GetRelease: %v", err) } if rel.IsTag { - if _, err = x.ID(rel.ID).Delete(new(Release)); err != nil { + if _, err = db.DefaultContext().Engine().ID(rel.ID).Delete(new(Release)); err != nil { return fmt.Errorf("Delete: %v", err) } } else { rel.IsDraft = true rel.NumCommits = 0 rel.Sha1 = "" - if _, err = x.ID(rel.ID).AllCols().Update(rel); err != nil { + if _, err = db.DefaultContext().Engine().ID(rel.ID).AllCols().Update(rel); err != nil { return fmt.Errorf("Update: %v", err) } } @@ -77,7 +79,7 @@ func SaveOrUpdateTag(repo *Repository, newRel *Release) error { if rel == nil { rel = newRel - if _, err = x.Insert(rel); err != nil { + if _, err = db.DefaultContext().Engine().Insert(rel); err != nil { return fmt.Errorf("InsertOne: %v", err) } } else { @@ -88,7 +90,7 @@ func SaveOrUpdateTag(repo *Repository, newRel *Release) error { if rel.IsTag && newRel.PublisherID > 0 { rel.PublisherID = newRel.PublisherID } - if _, err = x.ID(rel.ID).AllCols().Update(rel); err != nil { + if _, err = db.DefaultContext().Engine().ID(rel.ID).AllCols().Update(rel); err != nil { return fmt.Errorf("Update: %v", err) } } |