Skip to content

Commit 76b639b

Browse files
Add status checks.
1 parent 6a7d9d4 commit 76b639b

File tree

3 files changed

+35
-18
lines changed

3 files changed

+35
-18
lines changed

modules/convert/convert.go

+16-12
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,25 @@ func ToEmail(email *models.EmailAddress) *api.Email {
3333
func ToBranch(repo *models.Repository, b *git.Branch, c *git.Commit, bp *models.ProtectedBranch, user *models.User) *api.Branch {
3434
if bp == nil {
3535
return &api.Branch{
36-
Name: b.Name,
37-
Commit: ToCommit(repo, c),
38-
Protected: false,
39-
RequiredApprovals: 0,
40-
UserCanPush: true,
41-
UserCanMerge: true,
36+
Name: b.Name,
37+
Commit: ToCommit(repo, c),
38+
Protected: false,
39+
RequiredApprovals: 0,
40+
EnableStatusCheck: false,
41+
StatusCheckContexts: []string{},
42+
UserCanPush: true,
43+
UserCanMerge: true,
4244
}
4345
}
4446
return &api.Branch{
45-
Name: b.Name,
46-
Commit: ToCommit(repo, c),
47-
Protected: true,
48-
RequiredApprovals: bp.RequiredApprovals,
49-
UserCanPush: bp.CanUserPush(user.ID),
50-
UserCanMerge: bp.CanUserMerge(user.ID),
47+
Name: b.Name,
48+
Commit: ToCommit(repo, c),
49+
Protected: true,
50+
RequiredApprovals: bp.RequiredApprovals,
51+
EnableStatusCheck: bp.EnableStatusCheck,
52+
StatusCheckContexts: bp.StatusCheckContexts,
53+
UserCanPush: bp.CanUserPush(user.ID),
54+
UserCanMerge: bp.CanUserMerge(user.ID),
5155
}
5256
}
5357

modules/structs/repo_branch.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ package structs
66

77
// Branch represents a repository branch
88
type Branch struct {
9-
Name string `json:"name"`
10-
Commit *PayloadCommit `json:"commit"`
11-
Protected bool `json:"protected"`
12-
RequiredApprovals int64 `json:"required_approvals"`
13-
UserCanPush bool `json:"user_can_push"`
14-
UserCanMerge bool `json:"user_can_merge"`
9+
Name string `json:"name"`
10+
Commit *PayloadCommit `json:"commit"`
11+
Protected bool `json:"protected"`
12+
RequiredApprovals int64 `json:"required_approvals"`
13+
EnableStatusCheck bool `json:"enable_status_check"`
14+
StatusCheckContexts []string `json:"status_check_contexts"`
15+
UserCanPush bool `json:"user_can_push"`
16+
UserCanMerge bool `json:"user_can_merge"`
1517
}

templates/swagger/v1_json.tmpl

+11
Original file line numberDiff line numberDiff line change
@@ -7583,6 +7583,10 @@
75837583
"commit": {
75847584
"$ref": "#/definitions/PayloadCommit"
75857585
},
7586+
"enable_status_check": {
7587+
"type": "boolean",
7588+
"x-go-name": "EnableStatusCheck"
7589+
},
75867590
"name": {
75877591
"type": "string",
75887592
"x-go-name": "Name"
@@ -7596,6 +7600,13 @@
75967600
"format": "int64",
75977601
"x-go-name": "RequiredApprovals"
75987602
},
7603+
"status_check_contexts": {
7604+
"type": "array",
7605+
"items": {
7606+
"type": "string"
7607+
},
7608+
"x-go-name": "StatusCheckContexts"
7609+
},
75997610
"user_can_merge": {
76007611
"type": "boolean",
76017612
"x-go-name": "UserCanMerge"

0 commit comments

Comments
 (0)