-
Notifications
You must be signed in to change notification settings - Fork 168
/
pull_requests.go
74 lines (70 loc) · 2.26 KB
/
pull_requests.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package server
import (
"context"
"fmt"
"net/http"
)
// PullRequest represents a BitBucket Server pull request on a repository.
type PullRequest struct {
ID int `json:"id"`
Version int `json:"version"`
Title string `json:"title"`
Description string `json:"description"`
State string `json:"state"`
Open bool `json:"open"`
Closed bool `json:"closed"`
CreatedDate int64 `json:"createdDate"`
UpdatedDate int64 `json:"updatedDate"`
FromRef struct {
ID string `json:"id"`
DisplayID string `json:"displayId"`
LatestCommit string `json:"latestCommit"`
Repository Repository `json:"repository"`
} `json:"fromRef"`
ToRef struct {
ID string `json:"id"`
DisplayID string `json:"displayId"`
LatestCommit string `json:"latestCommit"`
Repository Repository `json:"repository"`
} `json:"toRef"`
Locked bool `json:"locked"`
Author struct {
User struct {
Name string `json:"name"`
EmailAddress string `json:"emailAddress"`
ID int `json:"id"`
DisplayName string `json:"displayName"`
Active bool `json:"active"`
Slug string `json:"slug"`
Type string `json:"type"`
Links struct {
Self []struct {
Href string `json:"href"`
} `json:"self"`
} `json:"links"`
} `json:"user"`
Role string `json:"role"`
Approved bool `json:"approved"`
Status string `json:"status"`
} `json:"author"`
Reviewers []interface{} `json:"reviewers"`
Participants []interface{} `json:"participants"`
Links struct {
Self []SelfLink `json:"self"`
} `json:"links"`
}
// PullRequestsService handles communication with the pull request related
type PullRequestsService struct {
v1Client *V1Client
}
// GetPullRequest get a specific pull request.
func (server *PullRequestsService) GetPullRequest(ctx context.Context, project string, repo string, number int) (*PullRequest, *http.Response, error) {
u := fmt.Sprintf("rest/api/1.0/projects/%s/repos/%s/pull-requests/%d", project, repo, number)
req, err := server.v1Client.NewRequest(http.MethodGet, u, nil, nil)
if err != nil {
return nil, nil, err
}
var pr PullRequest
resp, err := server.v1Client.Do(req, &pr)
return &pr, resp, err
}