Skip to content

Commit

Permalink
Update scanner commit limiting
Browse files Browse the repository at this point in the history
  • Loading branch information
owenrumney-f3 committed Feb 9, 2021
1 parent bac33fa commit 26754fe
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/app/squealer/scan/git_scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func newGitScanner(sc ScannerConfig) (*gitScanner, error) {
ignoreExtensions: sc.Cfg.IgnoreExtensions,
}
if len(sc.FromHash) > 0 {
fmt.Printf("setting the from hash to %s\n", sc.FromHash)
scanner.fromHash = plumbing.NewHash(sc.FromHash)
}

Expand All @@ -67,7 +68,8 @@ func (s *gitScanner) Scan() error {
fmt.Println(err.Error())
}
}(commit)
if commit.Hash == s.fromHash {
if commit.Hash.String() == s.fromHash.String() {
fmt.Println("commit hash reached - stopping")
// reached the starting commit - stop here
return nil
}
Expand All @@ -88,7 +90,10 @@ func (s *gitScanner) getRelevantCommitIter(client *git.Repository) (object.Commi
var err error

if headRef != nil {
commits, err = client.Log(&git.LogOptions{From: headRef.Hash()})
commits, err = client.Log(&git.LogOptions{
From: headRef.Hash(),
Order: git.LogOrderCommitterTime,
} )
if err != nil {
return nil, err
}
Expand All @@ -102,6 +107,7 @@ func (s *gitScanner) getRelevantCommitIter(client *git.Repository) (object.Commi
}

func (s *gitScanner) processCommit(commit *object.Commit) error {

files, err := commit.Files()
if err != nil {
return err
Expand Down

0 comments on commit 26754fe

Please sign in to comment.