diff options
author | Antoine GIRARD <sapk@users.noreply.github.com> | 2019-08-09 04:13:03 +0200 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2019-08-09 10:13:03 +0800 |
commit | 2b6f45299d6e96b633a309d68055f9ae0699b8f2 (patch) | |
tree | 85ebd068cafb64fdd987b36541a9e743f0744f4c /routers/api/v1/repo/git_ref.go | |
parent | c534b7e211d3264bbbde9b95cd8d6e9e60ad4215 (diff) | |
download | gitea-2b6f45299d6e96b633a309d68055f9ae0699b8f2.tar.gz gitea-2b6f45299d6e96b633a309d68055f9ae0699b8f2.zip |
api: fix multiple bugs with statuses endpoints (#7785)
* fix commit statuses api url
* search refs before passing sha
* adjust tests
* directly search tags and branches names + remove un-needed check in NewCommitStatus
* fix comment
* de-duplicate code
* test: use relative setting.AppURL
* Update routers/api/v1/repo/status.go
Co-Authored-By: Lauris BH <lauris@nix.lv>
* remove return
* Update routers/api/v1/repo/status.go
Co-Authored-By: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'routers/api/v1/repo/git_ref.go')
-rw-r--r-- | routers/api/v1/repo/git_ref.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/routers/api/v1/repo/git_ref.go b/routers/api/v1/repo/git_ref.go index e15f699a1d..d7acc139f0 100644 --- a/routers/api/v1/repo/git_ref.go +++ b/routers/api/v1/repo/git_ref.go @@ -71,19 +71,22 @@ func GetGitRefs(ctx *context.APIContext) { getGitRefsInternal(ctx, ctx.Params("*")) } -func getGitRefsInternal(ctx *context.APIContext, filter string) { +func getGitRefs(ctx *context.APIContext, filter string) ([]*git.Reference, string, error) { gitRepo, err := git.OpenRepository(ctx.Repo.Repository.RepoPath()) if err != nil { - ctx.Error(500, "OpenRepository", err) - return + return nil, "OpenRepository", err } if len(filter) > 0 { filter = "refs/" + filter } - refs, err := gitRepo.GetRefsFiltered(filter) + return refs, "GetRefsFiltered", err +} + +func getGitRefsInternal(ctx *context.APIContext, filter string) { + refs, lastMethodName, err := getGitRefs(ctx, filter) if err != nil { - ctx.Error(500, "GetRefsFiltered", err) + ctx.Error(500, lastMethodName, err) return } |