@@ -7,6 +7,7 @@ package bitbucket
77import (
88 "context"
99 "fmt"
10+ "strings"
1011 "time"
1112
1213 "github.com/jenkins-x/go-scm/scm"
@@ -17,7 +18,37 @@ type gitService struct {
1718}
1819
1920func (s * gitService ) FindRef (ctx context.Context , repo , ref string ) (string , * scm.Response , error ) {
20- panic ("implement me" )
21+ commit , res , err := s .FindCommit (ctx , repo , ref )
22+ if err != nil && res .Status != 404 {
23+ return "" , res , err
24+ }
25+ if commit != nil {
26+ if commit .Sha != "" {
27+ return commit .Sha , res , nil
28+ }
29+ }
30+ idx := strings .LastIndex (ref , "/" )
31+ if idx >= 0 {
32+ ref = ref [idx + 1 :]
33+ }
34+ return ref , nil , nil
35+
36+ /*
37+ path := fmt.Sprintf("2.0/repositories/%s/refs?%s", repo, encodeRefQueryOptions(ref))
38+ out := new(branches)
39+ res, err := s.client.do(ctx, "GET", path, nil, out)
40+ if debugDump {
41+ var buf bytes.Buffer
42+ res, err := s.client.do(ctx, "GET", path, nil, &buf)
43+ fmt.Printf("%s\n", buf.String())
44+ return "", res, err
45+ }
46+ branches := convertBranchList(out)
47+ if len(branches) == 0 {
48+ return "", res, err
49+ }
50+ return branches[0].Name, res, err
51+ */
2152}
2253
2354func (s * gitService ) DeleteRef (ctx context.Context , repo , ref string ) (* scm.Response , error ) {
0 commit comments