Skip to content

Commit

Permalink
Add status checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsvantesson committed Nov 15, 2019
1 parent 6a7d9d4 commit 76b639b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 18 deletions.
28 changes: 16 additions & 12 deletions modules/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,25 @@ func ToEmail(email *models.EmailAddress) *api.Email {
func ToBranch(repo *models.Repository, b *git.Branch, c *git.Commit, bp *models.ProtectedBranch, user *models.User) *api.Branch {
if bp == nil {
return &api.Branch{
Name: b.Name,
Commit: ToCommit(repo, c),
Protected: false,
RequiredApprovals: 0,
UserCanPush: true,
UserCanMerge: true,
Name: b.Name,
Commit: ToCommit(repo, c),
Protected: false,
RequiredApprovals: 0,
EnableStatusCheck: false,
StatusCheckContexts: []string{},
UserCanPush: true,
UserCanMerge: true,
}
}
return &api.Branch{
Name: b.Name,
Commit: ToCommit(repo, c),
Protected: true,
RequiredApprovals: bp.RequiredApprovals,
UserCanPush: bp.CanUserPush(user.ID),
UserCanMerge: bp.CanUserMerge(user.ID),
Name: b.Name,
Commit: ToCommit(repo, c),
Protected: true,
RequiredApprovals: bp.RequiredApprovals,
EnableStatusCheck: bp.EnableStatusCheck,
StatusCheckContexts: bp.StatusCheckContexts,
UserCanPush: bp.CanUserPush(user.ID),
UserCanMerge: bp.CanUserMerge(user.ID),
}
}

Expand Down
14 changes: 8 additions & 6 deletions modules/structs/repo_branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ package structs

// Branch represents a repository branch
type Branch struct {
Name string `json:"name"`
Commit *PayloadCommit `json:"commit"`
Protected bool `json:"protected"`
RequiredApprovals int64 `json:"required_approvals"`
UserCanPush bool `json:"user_can_push"`
UserCanMerge bool `json:"user_can_merge"`
Name string `json:"name"`
Commit *PayloadCommit `json:"commit"`
Protected bool `json:"protected"`
RequiredApprovals int64 `json:"required_approvals"`
EnableStatusCheck bool `json:"enable_status_check"`
StatusCheckContexts []string `json:"status_check_contexts"`
UserCanPush bool `json:"user_can_push"`
UserCanMerge bool `json:"user_can_merge"`
}
11 changes: 11 additions & 0 deletions templates/swagger/v1_json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7583,6 +7583,10 @@
"commit": {
"$ref": "#/definitions/PayloadCommit"
},
"enable_status_check": {
"type": "boolean",
"x-go-name": "EnableStatusCheck"
},
"name": {
"type": "string",
"x-go-name": "Name"
Expand All @@ -7596,6 +7600,13 @@
"format": "int64",
"x-go-name": "RequiredApprovals"
},
"status_check_contexts": {
"type": "array",
"items": {
"type": "string"
},
"x-go-name": "StatusCheckContexts"
},
"user_can_merge": {
"type": "boolean",
"x-go-name": "UserCanMerge"
Expand Down

0 comments on commit 76b639b

Please sign in to comment.