@@ -16,7 +16,7 @@ import (
16
16
func GetBranch (ctx * context.APIContext ) {
17
17
// swagger:operation GET /repos/{owner}/{repo}/branches/{branch} repository repoGetBranch
18
18
// ---
19
- // summary: Retrieve a specific branch from a repository
19
+ // summary: Retrieve a specific branch from a repository, including its effective branch protection
20
20
// produces:
21
21
// - application/json
22
22
// parameters:
@@ -61,7 +61,13 @@ func GetBranch(ctx *context.APIContext) {
61
61
return
62
62
}
63
63
64
- ctx .JSON (200 , convert .ToBranch (ctx .Repo .Repository , branch , c ))
64
+ branchProtection , err := ctx .Repo .Repository .GetBranchProtection (ctx .Repo .BranchName )
65
+ if err != nil {
66
+ ctx .Error (500 , "GetBranchProtection" , err )
67
+ return
68
+ }
69
+
70
+ ctx .JSON (200 , convert .ToBranch (ctx .Repo .Repository , branch , c , branchProtection , ctx .User ))
65
71
}
66
72
67
73
// ListBranches list all the branches of a repository
@@ -98,7 +104,12 @@ func ListBranches(ctx *context.APIContext) {
98
104
ctx .Error (500 , "GetCommit" , err )
99
105
return
100
106
}
101
- apiBranches [i ] = convert .ToBranch (ctx .Repo .Repository , branches [i ], c )
107
+ branchProtection , err := ctx .Repo .Repository .GetBranchProtection (branches [i ].Name )
108
+ if err != nil {
109
+ ctx .Error (500 , "GetBranchProtection" , err )
110
+ return
111
+ }
112
+ apiBranches [i ] = convert .ToBranch (ctx .Repo .Repository , branches [i ], c , branchProtection , ctx .User )
102
113
}
103
114
104
115
ctx .JSON (200 , & apiBranches )
0 commit comments