Skip to content

Commit ed2b926

Browse files
committed
fixes issue #27
1 parent 635e46e commit ed2b926

File tree

8 files changed

+46
-1
lines changed

8 files changed

+46
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## Unreleased
88
### Added
9+
- Improve status display text in new bitbucket pull request screen, from [@bradrydzewski](https://github.com/bradrydzewski). See [#27](https://github.com/drone/go-scm/issues/27).
910

1011
## [1.6.0]
1112
### Added
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright 2017 Drone.IO Inc. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
// Package integration implements a Bitbucket Cloud integration
6+
// tests.
7+
package integration
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2017 Drone.IO Inc. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package integration
6+
7+
import (
8+
"context"
9+
"net/http"
10+
"os"
11+
"testing"
12+
13+
"github.com/drone/go-scm/scm/driver/bitbucket"
14+
"github.com/drone/go-scm/scm/transport"
15+
)
16+
17+
var noContext = context.Background()
18+
19+
func TestIntegration(t *testing.T) {
20+
client := bitbucket.NewDefault()
21+
client.Client = &http.Client{
22+
Transport: &transport.BearerToken{
23+
Token: os.Getenv("BITBUCKET_TOKEN"),
24+
},
25+
}
26+
}

scm/driver/bitbucket/repo.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ func (s *repositoryService) CreateStatus(ctx context.Context, repo, ref string,
142142
path := fmt.Sprintf("2.0/repositories/%s/commit/%s/statuses/build", repo, ref)
143143
in := &status{
144144
State: convertFromState(input.State),
145+
Name: input.Title,
145146
Desc: input.Desc,
146147
Key: input.Label,
147148
URL: input.Target,
@@ -282,6 +283,7 @@ func convertStatus(from *status) *scm.Status {
282283
return &scm.Status{
283284
State: convertState(from.State),
284285
Label: from.Key,
286+
Title: from.Name,
285287
Desc: from.Desc,
286288
Target: from.URL,
287289
}

scm/driver/bitbucket/repo_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ func TestStatusCreate(t *testing.T) {
176176
File("testdata/status.json")
177177

178178
in := &scm.StatusInput{
179+
Title: "BUILD-22",
179180
Desc: "Build has completed successfully",
180181
Label: "continuous-integration/drone",
181182
State: scm.StateSuccess,

scm/driver/bitbucket/testdata/status.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@
4444
},
4545
"updated_on": "2018-07-01T20:27:45.726774+00:00",
4646
"type": "build",
47-
"name": ""
47+
"name": "build-22"
4848
}

scm/driver/bitbucket/testdata/status.json.golden

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"State": 3,
33
"Label": "drone",
44
"Desc": "Build has completed successfully",
5+
"Title": "build-22",
56
"Target": "https://ci.example.com/1000/output"
67
}

scm/repo.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,20 @@ type (
7676
Label string
7777
Desc string
7878
Target string
79+
80+
// TODO(bradrydzewski) this field is only used
81+
// by Bitbucket which requires a user-defined
82+
// key (label), title and description. We need
83+
// to cleanup this abstraction.
84+
Title string
7985
}
8086

8187
// StatusInput provides the input fields required for
8288
// creating or updating commit statuses.
8389
StatusInput struct {
8490
State State
8591
Label string
92+
Title string
8693
Desc string
8794
Target string
8895
}

0 commit comments

Comments
 (0)