Gitea incorrect API call

Using drone/drone:latest and gitea/gitea:1.10.


Drone API calls POST /api/repos/{namespace}/{name}/builds and POST /api/repos/{namespace}/{name}/builds?branch={branch} do not work for a Gitea repo. These API calls trigger an incorrect API call to Gitea, being GET /api/v1/repos/{owner}/{repo}/git/commits/{ref} instead of GET /api/v1/repos/{owner}/{repo}/git/refs/{ref}.

As seen in drone/service/commit/commit.go lines 45 and 90, the same function FindCommit() is used to perform API requests for both commits and refs, hence leading to the wrong API call being made for refs.

Suggested solution:

Add an extra function FindCommitByRef() in go-scm/scm/driver/gitea/git.go and other drivers which performs the correct API call.

A pull request with the proposed solution has been made: Fix gitea API call for triggering pipelines #50.

Hi, should this work on gitea 1.12? I still get 404 error on calling POST /api/repos/{namespace}/{name}/builds. on gitea 1.12

These routes works ok:

GET /api/repos/{owner}/{repo}/builds/{build}
GET /api/repos/{owner}/{repo}/builds

The issue was resolved by #61. It worked on Gitea 1.11, but I have not tested it with Gitea 1.12. At the moment, drone/go-scm has not been bumped to a version including #61 in go.mod from drone/drone. So make sure to use the latest drone/go-scm version when building drone-server from drone/drone.

Thank You very much. I wasn’t aware that the latest Drone Docker image doesn’t contains this fix. Now everything is clear for me. Thank You once again.