Browse Source

Fix bug on branch API (#10767)

for-closed-social
Lunny Xiao 4 years ago
committed by GitHub
parent
commit
83fe7d414e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions
  1. +7
    -3
      modules/convert/convert.go

+ 7
- 3
modules/convert/convert.go View File

@ -49,17 +49,21 @@ func ToBranch(repo *models.Repository, b *git.Branch, c *git.Commit, bp *models.
branchProtectionName = bp.BranchName branchProtectionName = bp.BranchName
} }
return &api.Branch{
branch := &api.Branch{
Name: b.Name, Name: b.Name,
Commit: ToCommit(repo, c), Commit: ToCommit(repo, c),
Protected: true, Protected: true,
RequiredApprovals: bp.RequiredApprovals, RequiredApprovals: bp.RequiredApprovals,
EnableStatusCheck: bp.EnableStatusCheck, EnableStatusCheck: bp.EnableStatusCheck,
StatusCheckContexts: bp.StatusCheckContexts, StatusCheckContexts: bp.StatusCheckContexts,
UserCanPush: bp.CanUserPush(user.ID),
UserCanMerge: bp.IsUserMergeWhitelisted(user.ID),
EffectiveBranchProtectionName: branchProtectionName, 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 // ToBranchProtection convert a ProtectedBranch to api.BranchProtection

Loading…
Cancel
Save