@@ -19,7 +19,6 @@ package enforce
19
19
import (
20
20
"context"
21
21
"fmt"
22
- "net/http"
23
22
"sync"
24
23
"time"
25
24
@@ -49,7 +48,6 @@ var getAppInstallationRepos func(context.Context, *github.Client) ([]*github.Rep
49
48
var runPolicies func (context.Context , * github.Client , string , string , bool , string ) (EnforceRepoResults , error )
50
49
var deleteInstallation func (context.Context , * github.Client , int64 ) (* github.Response , error )
51
50
var listInstallations func (context.Context , * github.Client ) ([]* github.Installation , error )
52
- var isRepositoryEmpty func (context.Context , * github.Client , string , string , string ) (bool , error )
53
51
54
52
func init () {
55
53
policiesGetPolicies = policies .GetPolicies
@@ -61,7 +59,6 @@ func init() {
61
59
runPolicies = runPoliciesReal
62
60
deleteInstallation = deleteInstallationReal
63
61
listInstallations = listInstallationsReal
64
- isRepositoryEmpty = isRepositoryEmptyReal
65
62
}
66
63
67
64
// EnforceAll iterates through all available installations and repos Allstar
@@ -321,25 +318,6 @@ func EnforceJob(ctx context.Context, ghc *ghclients.GHClients, d time.Duration,
321
318
}
322
319
}
323
320
324
- // returns true if the repository has content and false if it's empty
325
- func isRepositoryEmptyReal (ctx context.Context , c * github.Client , owner , repo , policy string ) (bool , error ) {
326
- opts := github.RepositoryContentGetOptions {}
327
- file , dirs , resp , err := c .Repositories .GetContents (ctx , owner , repo , "" , & opts )
328
- if err != nil && resp .StatusCode != http .StatusNotFound {
329
- return false , err
330
- }
331
- if file == nil && len (dirs ) == 0 {
332
- log .Info ().
333
- Str ("org" , owner ).
334
- Str ("repo" , repo ).
335
- Str ("area" , policy ).
336
- Msg ("Repository is empty, skipping" )
337
- return true , nil
338
- }
339
-
340
- return false , nil
341
- }
342
-
343
321
// runPoliciesReal enforces policies on the provided repo. It is meant to be called
344
322
// from either jobs, webhooks, or delayed checks. TODO: implement concurrency
345
323
// check to only run a single instance per repo at a time.
@@ -373,15 +351,6 @@ func runPoliciesReal(ctx context.Context, c *github.Client, owner, repo string,
373
351
continue
374
352
}
375
353
376
- isEmpty , err := isRepositoryEmpty (ctx , c , owner , repo , p .Name ())
377
- if err != nil {
378
- return nil , err
379
- }
380
-
381
- if isEmpty {
382
- continue
383
- }
384
-
385
354
r , err := p .Check (ctx , c , owner , repo )
386
355
if err != nil {
387
356
return nil , err
0 commit comments