bitbucket needs to get ref via branch, cant via heads

This commit is contained in:
Ilan Pillemer 2019-06-16 00:56:06 +01:00
parent 3deb69886a
commit c39ceb4ecb

View file

@ -16,7 +16,6 @@ package commit
import (
"context"
"github.com/drone/drone/core"
"github.com/drone/go-scm/scm"
)
@ -77,6 +76,17 @@ func (s *service) FindRef(ctx context.Context, user *core.User, repo, ref string
Token: user.Token,
Refresh: user.Refresh,
})
switch s.client.Driver {
case scm.DriverBitbucket:
ref = scm.TrimRef(ref)
branch, _, err := s.client.Git.FindBranch(ctx, repo, ref) // wont work for a Tag
if err != nil {
return nil, err
}
ref = branch.Sha
}
commit, _, err := s.client.Git.FindCommit(ctx, repo, ref)
if err != nil {
return nil, err