Synchronization tool file history tests modified to set up a temporary git repo (#138)

This commit is contained in:
Domas Monkus 2020-11-03 11:19:36 +02:00 committed by GitHub
parent e8103502da
commit 54637e7313
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 122 additions and 46 deletions

View file

@ -22,6 +22,7 @@ var ErrNotFound = fmt.Errorf("not found")
func FileHistory(path string, repo *git.Repository) ([]string, error) {
logOpts := git.LogOptions{
FileName: &path,
All: true,
}
commits, err := repo.Log(&logOpts)
if errors.Is(err, plumbing.ErrReferenceNotFound) {
@ -31,7 +32,6 @@ func FileHistory(path string, repo *git.Repository) ([]string, error) {
return nil, fmt.Errorf("failed to get commits for path %q: %v", path, err)
}
defer commits.Close()
hashHistory := []string{}
cerr := commits.ForEach(func(c *object.Commit) error {
root, err := repo.TreeObject(c.TreeHash)