From f186d4c898d0b039257134e399c95a00735103c2 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Tue, 23 May 2017 22:47:59 +0800 Subject: [PATCH] Gitea return a sha with the pull request Signed-off-by: Bo-Yi Wu --- remote/gitea/gitea.go | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/remote/gitea/gitea.go b/remote/gitea/gitea.go index 2ba6c1843..22da5043d 100644 --- a/remote/gitea/gitea.go +++ b/remote/gitea/gitea.go @@ -6,7 +6,6 @@ import ( "net" "net/http" "net/url" - "strings" "code.gitea.io/sdk/gitea" "github.com/drone/drone/model" @@ -229,24 +228,7 @@ func (c *client) Perm(u *model.User, owner, name string) (*model.Perm, error) { // File fetches the file from the Gitea repository and returns its contents. func (c *client) File(u *model.User, r *model.Repo, b *model.Build, f string) ([]byte, error) { client := c.newClientToken(u.Token) - ref := b.Commit - - // TODO gitea does not yet return a sha with the pull request - // so unfortunately we need to use the pull request branch. - if b.Event == model.EventPull { - ref = b.Branch - } - if ref == "" { - // Remove refs/tags or refs/heads, Gitea needs a short ref - ref = strings.TrimPrefix( - strings.TrimPrefix( - b.Ref, - "refs/heads/", - ), - "refs/tags/", - ) - } - cfg, err := client.GetFile(r.Owner, r.Name, ref, f) + cfg, err := client.GetFile(r.Owner, r.Name, b.Commit, f) return cfg, err }