@@ -264,18 +264,41 @@ func ListRepos(w http.ResponseWriter, r *http.Request) {
264
264
fail (w , http .StatusInternalServerError , "something went wrong" )
265
265
return
266
266
}
267
- repos := make ([]repoHooksInfo , len (userrepos ))
267
+ reposActive := make ([]repoHooksInfo , 0 , len (userrepos ))
268
+ reposInactive := make ([]repoHooksInfo , 0 , len (userrepos ))
269
+
270
+ checkActive := func (rhinfo repoHooksInfo ) bool {
271
+ // If at least one hook is not hooknone, return true
272
+ for _ , hook := range rhinfo .Hooks {
273
+ if hook .State != hooknone {
274
+ return true
275
+ }
276
+ }
277
+ return false
278
+ }
268
279
269
280
// TODO: Enum for hook states (see issue #5)
270
- for idx , rinfo := range userrepos {
281
+ for _ , rinfo := range userrepos {
271
282
repohooks , err := getRepoHooks (cl , rinfo .FullName )
272
283
if err != nil {
273
284
// simply initialise the map for now
274
285
repohooks = make (map [string ]ginhook )
275
286
}
276
- repos [idx ] = repoHooksInfo {rinfo , repohooks }
287
+ rhinfo := repoHooksInfo {rinfo , repohooks }
288
+ if checkActive (rhinfo ) {
289
+ reposActive = append (reposActive , rhinfo )
290
+ } else {
291
+ reposInactive = append (reposInactive , rhinfo )
292
+ }
293
+ }
294
+ allrepos := struct {
295
+ Active []repoHooksInfo
296
+ Inactive []repoHooksInfo
297
+ }{
298
+ reposActive ,
299
+ reposInactive ,
277
300
}
278
- tmpl .Execute (w , & repos )
301
+ tmpl .Execute (w , & allrepos )
279
302
}
280
303
281
304
// matchValidator receives a URL path from a GIN hook and returns the validator
@@ -362,7 +385,7 @@ func getRepoHooks(cl *ginclient.Client, repopath string) (map[string]ginhook, er
362
385
hooks [validator ] = ginhook {validator , hook .ID , state }
363
386
// TODO: Check if the same validator is found twice
364
387
}
365
- // add supported validators that were not found and mark them disabled
388
+ // add supported validators that were not found and mark them hooknone
366
389
supportedValidators := config .Read ().Settings .Validators
367
390
for _ , validator := range supportedValidators {
368
391
if _ , ok := hooks [validator ]; ! ok {
0 commit comments