Skip to content

Commit

Permalink
pkg/vcs/git: fetch commits not older than five years
Browse files Browse the repository at this point in the history
Increase the maximum age of fetched commits when searching for fix tags
and commit titles. This enables syz-ci to find older commits provided with
'#syz fix' commands.

https://groups.google.com/g/syzkaller/c/nbd2tUr5AhU

Signed-off-by: Alexander Egorenkov <eaibmz@gmail>
  • Loading branch information
eaibmz authored and dvyukov committed May 10, 2022
1 parent 1b75de9 commit 9275589
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/vcs/git.go
Expand Up @@ -308,6 +308,10 @@ func (git *git) GetCommitByTitle(title string) (*Commit, error) {
return commits[0], nil
}

const (
fetchCommitsMaxAgeInYears = 5
)

func (git *git) GetCommitsByTitles(titles []string) ([]*Commit, []string, error) {
var greps []string
m := make(map[string]string)
Expand All @@ -316,7 +320,7 @@ func (git *git) GetCommitsByTitles(titles []string) ([]*Commit, []string, error)
greps = append(greps, canonical)
m[canonical] = title
}
since := time.Now().Add(-time.Hour * 24 * 365 * 2).Format("01-02-2006")
since := time.Now().Add(-time.Hour * 24 * 365 * fetchCommitsMaxAgeInYears).Format("01-02-2006")
commits, err := git.fetchCommits(since, "HEAD", "", "", greps, true)
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -354,7 +358,7 @@ func (git *git) ExtractFixTagsFromCommits(baseCommit, email string) ([]*Commit,
return nil, fmt.Errorf("failed to parse email %q: %v", email, err)
}
grep := user + "+.*" + domain
since := time.Now().Add(-time.Hour * 24 * 365).Format("01-02-2006")
since := time.Now().Add(-time.Hour * 24 * 365 * fetchCommitsMaxAgeInYears).Format("01-02-2006")
return git.fetchCommits(since, baseCommit, user, domain, []string{grep}, false)
}

Expand Down

0 comments on commit 9275589

Please sign in to comment.