api: fix multiple bugs with statuses endpoints (#7785) (#7807)

* 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>
This commit is contained in:
Antoine GIRARD 2019-08-09 15:18:46 +02:00 committed by Lauris BH
parent 4f39e56795
commit 38e799779f
5 changed files with 85 additions and 23 deletions

View file

@ -87,7 +87,7 @@ func (status *CommitStatus) loadRepo(e Engine) (err error) {
// APIURL returns the absolute APIURL to this commit-status.
func (status *CommitStatus) APIURL() string {
_ = status.loadRepo(x)
return fmt.Sprintf("%sapi/v1/%s/statuses/%s",
return fmt.Sprintf("%sapi/v1/repos/%s/statuses/%s",
setting.AppURL, status.Repo.FullName(), status.SHA)
}