File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -95,8 +95,7 @@ func (handler *branchesHandler) setup() error {
9595 handler .errSetup = sce .Create (sce .ErrScorecardInternal , fmt .Sprintf ("githubv4.Query: %v" , err ))
9696 }
9797 handler .defaultBranchRef = getBranchRefFrom (handler .data .Repository .DefaultBranchRef )
98- handler .branches = getBranchRefsFrom (handler .data .Repository .Refs .Nodes )
99- // Maybe add defaultBranchRef to branches.
98+ handler .branches = getBranchRefsFrom (handler .data .Repository .Refs .Nodes , handler .defaultBranchRef )
10099 })
101100 return handler .errSetup
102101}
@@ -194,10 +193,18 @@ func getBranchRefFrom(data branch) *clients.BranchRef {
194193 return branchRef
195194}
196195
197- func getBranchRefsFrom (data []branch ) []* clients.BranchRef {
196+ func getBranchRefsFrom (data []branch , defaultBranch * clients. BranchRef ) []* clients.BranchRef {
198197 branchRefs := make ([]* clients.BranchRef , len (data ))
198+ var defaultFound bool
199199 for i , b := range data {
200200 branchRefs [i ] = getBranchRefFrom (b )
201+ if defaultBranch != nil && branchRefs [i ].Name == defaultBranch .Name {
202+ defaultFound = true
203+ }
204+ }
205+ if ! defaultFound {
206+ // nolint: makezero
207+ branchRefs = append (branchRefs , defaultBranch )
201208 }
202209 return branchRefs
203210}
You can’t perform that action at this time.
0 commit comments