aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1
diff options
context:
space:
mode:
Diffstat (limited to 'routers/api/v1')
-rw-r--r--routers/api/v1/org/team.go2
-rw-r--r--routers/api/v1/repo/fork.go5
-rw-r--r--routers/api/v1/repo/hook.go2
-rw-r--r--routers/api/v1/repo/key.go4
-rw-r--r--routers/api/v1/repo/migrate.go2
-rw-r--r--routers/api/v1/repo/repo.go11
-rw-r--r--routers/api/v1/repo/status.go2
-rw-r--r--routers/api/v1/repo/transfer.go2
-rw-r--r--routers/api/v1/user/repo.go5
-rw-r--r--routers/api/v1/user/star.go3
-rw-r--r--routers/api/v1/user/watch.go3
11 files changed, 23 insertions, 18 deletions
diff --git a/routers/api/v1/org/team.go b/routers/api/v1/org/team.go
index 443784fb8b..72387dcbf7 100644
--- a/routers/api/v1/org/team.go
+++ b/routers/api/v1/org/team.go
@@ -492,7 +492,7 @@ func GetTeamRepos(ctx *context.APIContext) {
ctx.Error(http.StatusInternalServerError, "GetTeamRepos", err)
return
}
- repos[i] = repo.APIFormat(access)
+ repos[i] = convert.ToRepo(repo, access)
}
ctx.JSON(http.StatusOK, repos)
}
diff --git a/routers/api/v1/repo/fork.go b/routers/api/v1/repo/fork.go
index e6f5f5e630..24700f7a7f 100644
--- a/routers/api/v1/repo/fork.go
+++ b/routers/api/v1/repo/fork.go
@@ -11,6 +11,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"
repo_service "code.gitea.io/gitea/services/repository"
@@ -58,7 +59,7 @@ func ListForks(ctx *context.APIContext) {
ctx.Error(http.StatusInternalServerError, "AccessLevel", err)
return
}
- apiForks[i] = fork.APIFormat(access)
+ apiForks[i] = convert.ToRepo(fork, access)
}
ctx.JSON(http.StatusOK, apiForks)
}
@@ -125,5 +126,5 @@ func CreateFork(ctx *context.APIContext, form api.CreateForkOption) {
}
//TODO change back to 201
- ctx.JSON(http.StatusAccepted, fork.APIFormat(models.AccessModeOwner))
+ ctx.JSON(http.StatusAccepted, convert.ToRepo(fork, models.AccessModeOwner))
}
diff --git a/routers/api/v1/repo/hook.go b/routers/api/v1/repo/hook.go
index 1a38fc3018..fc8b33a7ca 100644
--- a/routers/api/v1/repo/hook.go
+++ b/routers/api/v1/repo/hook.go
@@ -146,7 +146,7 @@ func TestHook(ctx *context.APIContext) {
Commits: []*api.PayloadCommit{
convert.ToPayloadCommit(ctx.Repo.Repository, ctx.Repo.Commit),
},
- Repo: ctx.Repo.Repository.APIFormat(models.AccessModeNone),
+ Repo: convert.ToRepo(ctx.Repo.Repository, models.AccessModeNone),
Pusher: convert.ToUser(ctx.User, ctx.IsSigned, false),
Sender: convert.ToUser(ctx.User, ctx.IsSigned, false),
}); err != nil {
diff --git a/routers/api/v1/repo/key.go b/routers/api/v1/repo/key.go
index 3d16ae6d40..3e6174f621 100644
--- a/routers/api/v1/repo/key.go
+++ b/routers/api/v1/repo/key.go
@@ -21,13 +21,13 @@ import (
func appendPrivateInformation(apiKey *api.DeployKey, key *models.DeployKey, repository *models.Repository) (*api.DeployKey, error) {
apiKey.ReadOnly = key.Mode == models.AccessModeRead
if repository.ID == key.RepoID {
- apiKey.Repository = repository.APIFormat(key.Mode)
+ apiKey.Repository = convert.ToRepo(repository, key.Mode)
} else {
repo, err := models.GetRepositoryByID(key.RepoID)
if err != nil {
return apiKey, err
}
- apiKey.Repository = repo.APIFormat(key.Mode)
+ apiKey.Repository = convert.ToRepo(repo, key.Mode)
}
return apiKey, nil
}
diff --git a/routers/api/v1/repo/migrate.go b/routers/api/v1/repo/migrate.go
index 68ab7e4897..511e91f94e 100644
--- a/routers/api/v1/repo/migrate.go
+++ b/routers/api/v1/repo/migrate.go
@@ -191,7 +191,7 @@ func Migrate(ctx *context.APIContext, form api.MigrateRepoOptions) {
}
log.Trace("Repository migrated: %s/%s", repoOwner.Name, form.RepoName)
- ctx.JSON(http.StatusCreated, repo.APIFormat(models.AccessModeAdmin))
+ ctx.JSON(http.StatusCreated, convert.ToRepo(repo, models.AccessModeAdmin))
}
func handleMigrateError(ctx *context.APIContext, repoOwner *models.User, remoteAddr string, err error) {
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go
index 116e413125..048f7d6b1f 100644
--- a/routers/api/v1/repo/repo.go
+++ b/routers/api/v1/repo/repo.go
@@ -12,6 +12,7 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/context"
+ "code.gitea.io/gitea/modules/convert"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
@@ -217,7 +218,7 @@ func Search(ctx *context.APIContext) {
Error: err.Error(),
})
}
- results[i] = repo.APIFormat(accessMode)
+ results[i] = convert.ToRepo(repo, accessMode)
}
ctx.SetLinkHeader(int(count), opts.PageSize)
@@ -265,7 +266,7 @@ func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateR
ctx.Error(http.StatusInternalServerError, "GetRepositoryByID", err)
}
- ctx.JSON(http.StatusCreated, repo.APIFormat(models.AccessModeOwner))
+ ctx.JSON(http.StatusCreated, convert.ToRepo(repo, models.AccessModeOwner))
}
// Create one repository of mine
@@ -406,7 +407,7 @@ func Get(ctx *context.APIContext) {
// "200":
// "$ref": "#/responses/Repository"
- ctx.JSON(http.StatusOK, ctx.Repo.Repository.APIFormat(ctx.Repo.AccessMode))
+ ctx.JSON(http.StatusOK, convert.ToRepo(ctx.Repo.Repository, ctx.Repo.AccessMode))
}
// GetByID returns a single Repository
@@ -445,7 +446,7 @@ func GetByID(ctx *context.APIContext) {
ctx.NotFound()
return
}
- ctx.JSON(http.StatusOK, repo.APIFormat(perm.AccessMode))
+ ctx.JSON(http.StatusOK, convert.ToRepo(repo, perm.AccessMode))
}
// Edit edit repository properties
@@ -494,7 +495,7 @@ func Edit(ctx *context.APIContext, opts api.EditRepoOption) {
}
}
- ctx.JSON(http.StatusOK, ctx.Repo.Repository.APIFormat(ctx.Repo.AccessMode))
+ ctx.JSON(http.StatusOK, convert.ToRepo(ctx.Repo.Repository, ctx.Repo.AccessMode))
}
// updateBasicProperties updates the basic properties of a repo: Name, Description, Website and Visibility
diff --git a/routers/api/v1/repo/status.go b/routers/api/v1/repo/status.go
index e7318edaa5..3b6d9b04c1 100644
--- a/routers/api/v1/repo/status.go
+++ b/routers/api/v1/repo/status.go
@@ -300,7 +300,7 @@ func GetCombinedCommitStatusByRef(ctx *context.APIContext) {
retStatus := &combinedCommitStatus{
SHA: sha,
TotalCount: len(statuses),
- Repo: repo.APIFormat(ctx.Repo.AccessMode),
+ Repo: convert.ToRepo(repo, ctx.Repo.AccessMode),
URL: "",
}
diff --git a/routers/api/v1/repo/transfer.go b/routers/api/v1/repo/transfer.go
index b1271b7721..a0999a6ce2 100644
--- a/routers/api/v1/repo/transfer.go
+++ b/routers/api/v1/repo/transfer.go
@@ -105,5 +105,5 @@ func Transfer(ctx *context.APIContext, opts api.TransferRepoOption) {
}
log.Trace("Repository transferred: %s -> %s", ctx.Repo.Repository.FullName(), newOwner.Name)
- ctx.JSON(http.StatusAccepted, newRepo.APIFormat(models.AccessModeAdmin))
+ ctx.JSON(http.StatusAccepted, convert.ToRepo(newRepo, models.AccessModeAdmin))
}
diff --git a/routers/api/v1/user/repo.go b/routers/api/v1/user/repo.go
index ae5e319c27..b17841e67a 100644
--- a/routers/api/v1/user/repo.go
+++ b/routers/api/v1/user/repo.go
@@ -10,6 +10,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"
)
@@ -37,7 +38,7 @@ func listUserRepos(ctx *context.APIContext, u *models.User, private bool) {
return
}
if ctx.IsSigned && ctx.User.IsAdmin || access >= models.AccessModeRead {
- apiRepos = append(apiRepos, repos[i].APIFormat(access))
+ apiRepos = append(apiRepos, convert.ToRepo(repos[i], access))
}
}
@@ -125,7 +126,7 @@ func ListMyRepos(ctx *context.APIContext) {
if err != nil {
ctx.Error(http.StatusInternalServerError, "AccessLevel", err)
}
- results[i] = repo.APIFormat(accessMode)
+ results[i] = convert.ToRepo(repo, accessMode)
}
ctx.SetLinkHeader(int(count), opts.ListOptions.PageSize)
diff --git a/routers/api/v1/user/star.go b/routers/api/v1/user/star.go
index 1fc1005810..937dcb477f 100644
--- a/routers/api/v1/user/star.go
+++ b/routers/api/v1/user/star.go
@@ -10,6 +10,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"
)
@@ -28,7 +29,7 @@ func getStarredRepos(user *models.User, private bool, listOptions models.ListOpt
if err != nil {
return nil, err
}
- repos[i] = starred.APIFormat(access)
+ repos[i] = convert.ToRepo(starred, access)
}
return repos, nil
}
diff --git a/routers/api/v1/user/watch.go b/routers/api/v1/user/watch.go
index 9ad8682f5f..ab656f3229 100644
--- a/routers/api/v1/user/watch.go
+++ b/routers/api/v1/user/watch.go
@@ -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"
)
@@ -27,7 +28,7 @@ func getWatchedRepos(user *models.User, private bool, listOptions models.ListOpt
if err != nil {
return nil, err
}
- repos[i] = watched.APIFormat(access)
+ repos[i] = convert.ToRepo(watched, access)
}
return repos, nil
}