@@ -106,6 +106,14 @@ func (b *Base) PreparePRContext(ctx context.Context, installationID int64, pr *g
106106}
107107
108108func (b * Base ) NewEvalContext (ctx context.Context , installationID int64 , loc pull.Locator ) (* EvalContext , error ) {
109+ return b .newEvalContext (ctx , installationID , loc , nil )
110+ }
111+
112+ func (b * Base ) newEvalContextWithConfig (ctx context.Context , installationID int64 , loc pull.Locator , fetchedConfig FetchedConfig ) (* EvalContext , error ) {
113+ return b .newEvalContext (ctx , installationID , loc , & fetchedConfig )
114+ }
115+
116+ func (b * Base ) newEvalContext (ctx context.Context , installationID int64 , loc pull.Locator , fetchedConfig * FetchedConfig ) (* EvalContext , error ) {
109117 client , err := b .NewInstallationClient (installationID )
110118 if err != nil {
111119 return nil , err
@@ -122,17 +130,13 @@ func (b *Base) NewEvalContext(ctx context.Context, installationID int64, loc pul
122130 return nil , err
123131 }
124132
125- // Start background fetches for commonly needed data
126- // This overlaps API calls with the config fetch below
127- if ghctx , ok := prctx .(* pull.GitHubContext ); ok {
128- ghctx .Prefetch ()
129- }
130-
131133 baseBranch , _ := prctx .Branches ()
132134 owner := prctx .RepositoryOwner ()
133135 repository := prctx .RepositoryName ()
134136
135- fetchedConfig := b .ConfigFetcher .ConfigForRepositoryBranch (ctx , client , owner , repository , baseBranch )
137+ if fetchedConfig == nil {
138+ fetchedConfig = github .Ptr (b .ConfigFetcher .ConfigForRepositoryBranch (ctx , client , owner , repository , baseBranch ))
139+ }
136140
137141 return & EvalContext {
138142 Client : client ,
@@ -142,7 +146,7 @@ func (b *Base) NewEvalContext(ctx context.Context, installationID int64, loc pul
142146 PublicURL : b .BaseConfig .PublicURL ,
143147
144148 PullContext : prctx ,
145- Config : fetchedConfig ,
149+ Config : * fetchedConfig ,
146150 }, nil
147151}
148152
0 commit comments