mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-06 02:15:20 +02:00
[Refactor] Move APIFormat functions into convert package (#12856)
* USER APIFormat -> ToUser * Migrate more and mark APIFormat deprecated * models.Comment APIFormat() -> convert.ToComment * models.Release APIFormat() -> convert.ToRelease * models.Attachments APIFormat() -> convert.ToReleaseAttachments * models.CommitStatus APIFormat() -> convert.ToCommitStatus * finish migration to convert.ToUser * Move Test * Imprufe Test * fix test Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
parent
131278ff22
commit
d453533beb
28 changed files with 234 additions and 208 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/convert"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/routers/api/v1/utils"
|
||||
releaseservice "code.gitea.io/gitea/services/release"
|
||||
|
@ -60,7 +61,7 @@ func GetRelease(ctx *context.APIContext) {
|
|||
ctx.Error(http.StatusInternalServerError, "LoadAttributes", err)
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusOK, release.APIFormat())
|
||||
ctx.JSON(http.StatusOK, convert.ToRelease(release))
|
||||
}
|
||||
|
||||
// ListReleases list a repository's releases
|
||||
|
@ -117,7 +118,7 @@ func ListReleases(ctx *context.APIContext) {
|
|||
ctx.Error(http.StatusInternalServerError, "LoadAttributes", err)
|
||||
return
|
||||
}
|
||||
rels[i] = release.APIFormat()
|
||||
rels[i] = convert.ToRelease(release)
|
||||
}
|
||||
ctx.JSON(http.StatusOK, rels)
|
||||
}
|
||||
|
@ -205,7 +206,7 @@ func CreateRelease(ctx *context.APIContext, form api.CreateReleaseOption) {
|
|||
return
|
||||
}
|
||||
}
|
||||
ctx.JSON(http.StatusCreated, rel.APIFormat())
|
||||
ctx.JSON(http.StatusCreated, convert.ToRelease(rel))
|
||||
}
|
||||
|
||||
// EditRelease edit a release
|
||||
|
@ -288,7 +289,7 @@ func EditRelease(ctx *context.APIContext, form api.EditReleaseOption) {
|
|||
ctx.Error(http.StatusInternalServerError, "LoadAttributes", err)
|
||||
return
|
||||
}
|
||||
ctx.JSON(http.StatusOK, rel.APIFormat())
|
||||
ctx.JSON(http.StatusOK, convert.ToRelease(rel))
|
||||
}
|
||||
|
||||
// DeleteRelease delete a release from a repository
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue