Change summary
repository/gogit.go | 14 ++++++--------
repository/repo_testing.go | 2 +-
2 files changed, 7 insertions(+), 9 deletions(-)
Detailed changes
@@ -536,16 +536,14 @@ func (repo *GoGitRepo) ListCommits(ref string) ([]Hash, error) {
if err != nil {
return nil, err
}
- commits := []Hash{Hash(commit.Hash.String())}
+ hashes := []Hash{Hash(commit.Hash.String())}
for {
commit, err = commit.Parent(0)
-
+ if err == object.ErrParentNotFound {
+ break
+ }
if err != nil {
- if err == object.ErrParentNotFound {
- break
- }
-
return nil, err
}
@@ -553,10 +551,10 @@ func (repo *GoGitRepo) ListCommits(ref string) ([]Hash, error) {
return nil, fmt.Errorf("multiple parents")
}
- commits = append(commits, Hash(commit.Hash.String()))
+ hashes = append([]Hash{Hash(commit.Hash.String())}, hashes...)
}
- return commits, nil
+ return hashes, nil
}
// GetOrCreateClock return a Lamport clock stored in the Repo.
@@ -188,7 +188,7 @@ func RepoDataTest(t *testing.T, repo RepoData) {
commits, err := repo.ListCommits("refs/bugs/ref2")
require.NoError(t, err)
- require.ElementsMatch(t, []Hash{commit1, commit2}, commits)
+ require.Equal(t, []Hash{commit1, commit2}, commits)
// Graph