Adding commit range feature via 'commit-to' and 'commit-from' options

This commit is contained in:
Zach Rice committed 2020-01-11 16:46:58 -05:00
1 parent 593edeae21
commit a0f72a4e35
11 files changed
+250 -9

No files matched your search

+7 -1
View File
@@ -339,8 +339,11 @@ func fileMatched(f interface{}, re *regexp.Regexp) bool {
// It is similar to `git log {branch}`. Default behavior is to log ALL branches so
// gitleaks gets the full git history.
func getLogOptions(repo *Repo) (*git.LogOptions, error) {
var logOpts git.LogOptions
if repo.Manager.Opts.CommitFrom != "" {
logOpts.From = plumbing.NewHash(repo.Manager.Opts.CommitFrom)
}
if repo.Manager.Opts.Branch != "" {
var logOpts git.LogOptions
refs, err := repo.Storer.IterReferences()
if err != nil {
return nil, err
@@ -368,6 +371,9 @@ func getLogOptions(repo *Repo) (*git.LogOptions, error) {
}
return &logOpts, nil
}
if !logOpts.From.IsZero() {
return &logOpts, nil
}
return &git.LogOptions{All: true}, nil
}