Skip to content

Commit

Permalink
Just keep commit count
Browse files Browse the repository at this point in the history
  • Loading branch information
bill-rich committed Jul 25, 2023
1 parent 94b3929 commit 99f7cce
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions pkg/sources/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type Git struct {
}

type metrics struct {
commitsScanned map[string]struct{}
commitsScanned int
}

func NewGit(sourceType sourcespb.SourceType, jobID, sourceID int64, sourceName string, verify bool, concurrency int,
Expand All @@ -70,9 +70,6 @@ func NewGit(sourceType sourcespb.SourceType, jobID, sourceID int64, sourceName s
sourceMetadataFunc: sourceMetadataFunc,
verify: verify,
concurrency: semaphore.NewWeighted(int64(concurrency)),
metrics: metrics{
commitsScanned: map[string]struct{}{},
},
}
}

Expand Down Expand Up @@ -347,7 +344,7 @@ func CloneRepoUsingSSH(ctx context.Context, gitUrl string, args ...string) (stri
return CloneRepo(ctx, userInfo, gitUrl, args...)
}

func (s *Git) CommitsScanned() map[string]struct{} {
func (s *Git) CommitsScanned() int {
return s.metrics.commitsScanned
}

Expand Down Expand Up @@ -383,7 +380,7 @@ func (s *Git) ScanCommits(ctx context.Context, repo *git.Repository, path string
break
}
depth++
s.metrics.commitsScanned[commit.Hash] = struct{}{}
s.metrics.commitsScanned++
logger.V(5).Info("scanning commit", "commit", commit.Hash)
for _, diff := range commit.Diffs {
if !scanOptions.Filter.Pass(diff.PathB) {
Expand Down

0 comments on commit 99f7cce

Please sign in to comment.