Synchronization tool file history tests modified to set up a temporary git repo (#138)
This commit is contained in:
parent
e8103502da
commit
54637e7313
6 changed files with 122 additions and 46 deletions
|
@ -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)
|
||||
|
|
Reference in a new issue