Skip to content

Commit

Permalink
fix issue with ignore on first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
owenrumney committed Mar 30, 2021
1 parent 1aa2120 commit 9b41971
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions internal/app/squealer/scan/git_scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package scan

import (
"bufio"
"io"
"os"
"sync"

"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/sirupsen/logrus"
log "github.com/sirupsen/logrus"
"io"
"os"
"sync"

"github.com/owenrumney/squealer/internal/app/squealer/match"
"github.com/owenrumney/squealer/internal/app/squealer/mertics"
Expand Down Expand Up @@ -211,19 +212,20 @@ func (s *gitScanner) processFile(cf CommitFile) error {
if isBin, err := file.IsBinary(); err != nil || isBin {
return nil
}
if shouldIgnore(cf.changePath, s.ignorePaths, s.ignoreExtensions) {

filepath := cf.changePath
if filepath == "" {
filepath = cf.file.Name
}

if shouldIgnore(filepath, s.ignorePaths, s.ignoreExtensions) {
return nil
}
content, err := file.Contents()
if err != nil {
return err
}

filepath := cf.changePath
if filepath == "" {
filepath = cf.file.Name
}

err = s.mc.Evaluate(filepath, content, cf.commit)
s.metrics.IncrementFilesProcessed()
return err
Expand Down

0 comments on commit 9b41971

Please sign in to comment.