Merge pull request #2733 from ilanpillemer/master

bitbucket needs to get ref via branch, cant via heads
This commit is contained in:
Brad Rydzewski 2019-07-29 21:19:41 -07:00 committed by GitHub
commit 1c87eba4ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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