@@ -202,6 +202,7 @@ func transform(src *object.Commit, tag *object.Tag) (dst *Commit) {
202
202
func (impl RepositoryManagerAnalyticsImpl ) ChangesSinceByRepositoryForAnalytics (gitCtx GitContext , checkoutPath string , Old string , New string ) (* GitChanges , error ) {
203
203
var err error
204
204
start := time .Now ()
205
+ useGitCli := impl .configuration .UseGitCli || impl .configuration .UseGitCliAnalytics
205
206
defer func () {
206
207
util .TriggerGitOperationMetrics ("changesSinceByRepositoryForAnalytics" , start , err )
207
208
}()
@@ -214,7 +215,7 @@ func (impl RepositoryManagerAnalyticsImpl) ChangesSinceByRepositoryForAnalytics(
214
215
oldHash := plumbing .NewHash (Old )
215
216
216
217
var fileStats FileStats
217
- if strings .Contains (checkoutPath , "/.git" ) || impl . configuration . UseGitCli {
218
+ if strings .Contains (checkoutPath , "/.git" ) || useGitCli {
218
219
oldHashString := oldHash .String ()
219
220
newHashString := newHash .String ()
220
221
fileStats , err = impl .gitManager .FetchDiffStatBetweenCommitsWithNumstat (gitCtx , oldHashString , newHashString , checkoutPath )
@@ -243,15 +244,16 @@ func (impl RepositoryManagerAnalyticsImpl) ChangesSinceByRepositoryForAnalytics(
243
244
func (impl RepositoryManagerAnalyticsImpl ) computeCommitDiff (gitCtx GitContext , checkoutPath string , oldHash plumbing.Hash , newHash plumbing.Hash , repository * GitRepository ) ([]* Commit , error ) {
244
245
var commitsCli , commitsGoGit []* Commit
245
246
var err error
246
- if impl .configuration .UseGitCli || impl .configuration .UseGitCliAnalytics || impl .configuration .AnalyticsDebug {
247
+ useGitCli := impl .configuration .UseGitCli || impl .configuration .UseGitCliAnalytics
248
+ if useGitCli || impl .configuration .AnalyticsDebug {
247
249
impl .logger .Infow ("Computing commit diff using cli " , "checkoutPath" , checkoutPath )
248
250
commitsCli , err = impl .gitManager .LogMergeBase (gitCtx , checkoutPath , oldHash .String (), newHash .String ())
249
251
if err != nil {
250
252
impl .logger .Errorw ("error in fetching commits for analytics through CLI: " , "err" , err )
251
253
return nil , err
252
254
}
253
255
}
254
- if ! ( impl . configuration . UseGitCli || impl . configuration . UseGitCliAnalytics ) || impl .configuration .AnalyticsDebug {
256
+ if ! useGitCli || impl .configuration .AnalyticsDebug {
255
257
impl .logger .Infow ("Computing commit diff using go-git " , "checkoutPath" , checkoutPath )
256
258
ctx , cancel := gitCtx .WithTimeout (impl .configuration .GoGitTimeout )
257
259
defer cancel ()
@@ -267,7 +269,7 @@ func (impl RepositoryManagerAnalyticsImpl) computeCommitDiff(gitCtx GitContext,
267
269
impl .logOldestCommitComparison (commitsGoGit , commitsCli , checkoutPath , oldHash .String (), newHash .String ())
268
270
}
269
271
270
- if ! impl . configuration . UseGitCli {
272
+ if ! useGitCli {
271
273
return commitsGoGit , nil
272
274
}
273
275
return commitsCli , nil
0 commit comments