Move newbranch to standalone package (#9627)

* Move newbranch to standalone package

* move branch functions to modules to avoid dependencies cycles

* fix tests

* fix lint

* fix lint
This commit is contained in:
Lunny Xiao 2020-01-14 11:38:04 +08:00 committed by GitHub
parent bca367cecc
commit 2677d071f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 208 additions and 183 deletions

View file

@ -11,6 +11,7 @@ import (
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/convert"
"code.gitea.io/gitea/modules/git"
repo_module "code.gitea.io/gitea/modules/repository"
api "code.gitea.io/gitea/modules/structs"
)
@ -48,7 +49,7 @@ func GetBranch(ctx *context.APIContext) {
ctx.NotFound()
return
}
branch, err := ctx.Repo.Repository.GetBranch(ctx.Repo.BranchName)
branch, err := repo_module.GetBranch(ctx.Repo.Repository, ctx.Repo.BranchName)
if err != nil {
if git.IsErrBranchNotExist(err) {
ctx.NotFound(err)
@ -95,7 +96,7 @@ func ListBranches(ctx *context.APIContext) {
// "200":
// "$ref": "#/responses/BranchList"
branches, err := ctx.Repo.Repository.GetBranches()
branches, err := repo_module.GetBranches(ctx.Repo.Repository)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetBranches", err)
return