Skip to content

Commit

Permalink
Fix bug on branch API (#10767)
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny authored Mar 19, 2020
1 parent 661289d commit 83fe7d4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions modules/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,21 @@ func ToBranch(repo *models.Repository, b *git.Branch, c *git.Commit, bp *models.
branchProtectionName = bp.BranchName
}

return &api.Branch{
branch := &api.Branch{
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.IsUserMergeWhitelisted(user.ID),
EffectiveBranchProtectionName: branchProtectionName,
}

if user != nil {
branch.UserCanPush = bp.CanUserPush(user.ID)
branch.UserCanMerge = bp.IsUserMergeWhitelisted(user.ID)
}
return branch
}

// ToBranchProtection convert a ProtectedBranch to api.BranchProtection
Expand Down

0 comments on commit 83fe7d4

Please sign in to comment.