diff options
Diffstat (limited to 'routers/web/repo/release.go')
-rw-r--r-- | routers/web/repo/release.go | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/routers/web/repo/release.go b/routers/web/repo/release.go index ab87c3e238..935813051a 100644 --- a/routers/web/repo/release.go +++ b/routers/web/repo/release.go @@ -12,6 +12,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/db" + repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/models/unit" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/base" @@ -33,7 +34,7 @@ const ( ) // calReleaseNumCommitsBehind calculates given release has how many commits behind release target. -func calReleaseNumCommitsBehind(repoCtx *context.Repository, release *models.Release, countCache map[string]int64) error { +func calReleaseNumCommitsBehind(repoCtx *context.Repository, release *repo_model.Release, countCache map[string]int64) error { // Fast return if release target is same as default branch. if repoCtx.BranchName == release.Target { release.NumCommitsBehind = repoCtx.CommitsCount - release.NumCommits @@ -115,25 +116,25 @@ func releasesOrTags(ctx *context.Context, isTagList bool) { writeAccess := ctx.Repo.CanWrite(unit.TypeReleases) ctx.Data["CanCreateRelease"] = writeAccess && !ctx.Repo.Repository.IsArchived - opts := models.FindReleasesOptions{ + opts := repo_model.FindReleasesOptions{ ListOptions: listOptions, IncludeDrafts: writeAccess && !isTagList, IncludeTags: isTagList, } - releases, err := models.GetReleasesByRepoID(ctx.Repo.Repository.ID, opts) + releases, err := repo_model.GetReleasesByRepoID(ctx.Repo.Repository.ID, opts) if err != nil { ctx.ServerError("GetReleasesByRepoID", err) return } - count, err := models.GetReleaseCountByRepoID(ctx.Repo.Repository.ID, opts) + count, err := repo_model.GetReleaseCountByRepoID(ctx.Repo.Repository.ID, opts) if err != nil { ctx.ServerError("GetReleaseCountByRepoID", err) return } - if err = models.GetReleaseAttachments(ctx, releases...); err != nil { + if err = repo_model.GetReleaseAttachments(ctx, releases...); err != nil { ctx.ServerError("GetReleaseAttachments", err) return } @@ -199,9 +200,9 @@ func SingleRelease(ctx *context.Context) { writeAccess := ctx.Repo.CanWrite(unit.TypeReleases) ctx.Data["CanCreateRelease"] = writeAccess && !ctx.Repo.Repository.IsArchived - release, err := models.GetRelease(ctx.Repo.Repository.ID, ctx.Params("*")) + release, err := repo_model.GetRelease(ctx.Repo.Repository.ID, ctx.Params("*")) if err != nil { - if models.IsErrReleaseNotExist(err) { + if repo_model.IsErrReleaseNotExist(err) { ctx.NotFound("GetRelease", err) return } @@ -209,7 +210,7 @@ func SingleRelease(ctx *context.Context) { return } - err = models.GetReleaseAttachments(ctx, release) + err = repo_model.GetReleaseAttachments(ctx, release) if err != nil { ctx.ServerError("GetReleaseAttachments", err) return @@ -241,15 +242,15 @@ func SingleRelease(ctx *context.Context) { return } - ctx.Data["Releases"] = []*models.Release{release} + ctx.Data["Releases"] = []*repo_model.Release{release} ctx.HTML(http.StatusOK, tplReleases) } // LatestRelease redirects to the latest release func LatestRelease(ctx *context.Context) { - release, err := models.GetLatestReleaseByRepoID(ctx.Repo.Repository.ID) + release, err := repo_model.GetLatestReleaseByRepoID(ctx.Repo.Repository.ID) if err != nil { - if models.IsErrReleaseNotExist(err) { + if repo_model.IsErrReleaseNotExist(err) { ctx.NotFound("LatestRelease", err) return } @@ -272,8 +273,8 @@ func NewRelease(ctx *context.Context) { ctx.Data["RequireTribute"] = true ctx.Data["tag_target"] = ctx.Repo.Repository.DefaultBranch if tagName := ctx.FormString("tag"); len(tagName) > 0 { - rel, err := models.GetRelease(ctx.Repo.Repository.ID, tagName) - if err != nil && !models.IsErrReleaseNotExist(err) { + rel, err := repo_model.GetRelease(ctx.Repo.Repository.ID, tagName) + if err != nil && !repo_model.IsErrReleaseNotExist(err) { ctx.ServerError("GetRelease", err) return } @@ -321,9 +322,9 @@ func NewReleasePost(ctx *context.Context) { attachmentUUIDs = form.Files } - rel, err := models.GetRelease(ctx.Repo.Repository.ID, form.TagName) + rel, err := repo_model.GetRelease(ctx.Repo.Repository.ID, form.TagName) if err != nil { - if !models.IsErrReleaseNotExist(err) { + if !repo_model.IsErrReleaseNotExist(err) { ctx.ServerError("GetRelease", err) return } @@ -363,7 +364,7 @@ func NewReleasePost(ctx *context.Context) { return } - rel = &models.Release{ + rel = &repo_model.Release{ RepoID: ctx.Repo.Repository.ID, Repo: ctx.Repo.Repository, PublisherID: ctx.Doer.ID, @@ -380,7 +381,7 @@ func NewReleasePost(ctx *context.Context) { if err = releaseservice.CreateRelease(ctx.Repo.GitRepo, rel, attachmentUUIDs, msg); err != nil { ctx.Data["Err_TagName"] = true switch { - case models.IsErrReleaseAlreadyExist(err): + case repo_model.IsErrReleaseAlreadyExist(err): ctx.RenderWithErr(ctx.Tr("repo.release.tag_name_already_exist"), tplReleaseNew, &form) case models.IsErrInvalidTagName(err): ctx.RenderWithErr(ctx.Tr("repo.release.tag_name_invalid"), tplReleaseNew, &form) @@ -427,9 +428,9 @@ func EditRelease(ctx *context.Context) { upload.AddUploadContext(ctx, "release") tagName := ctx.Params("*") - rel, err := models.GetRelease(ctx.Repo.Repository.ID, tagName) + rel, err := repo_model.GetRelease(ctx.Repo.Repository.ID, tagName) if err != nil { - if models.IsErrReleaseNotExist(err) { + if repo_model.IsErrReleaseNotExist(err) { ctx.NotFound("GetRelease", err) } else { ctx.ServerError("GetRelease", err) @@ -463,9 +464,9 @@ func EditReleasePost(ctx *context.Context) { ctx.Data["RequireTribute"] = true tagName := ctx.Params("*") - rel, err := models.GetRelease(ctx.Repo.Repository.ID, tagName) + rel, err := repo_model.GetRelease(ctx.Repo.Repository.ID, tagName) if err != nil { - if models.IsErrReleaseNotExist(err) { + if repo_model.IsErrReleaseNotExist(err) { ctx.NotFound("GetRelease", err) } else { ctx.ServerError("GetRelease", err) |