From 97aa7a04e66c593ef7c4fbc3d8871a135e99d06a Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 26 Apr 2025 16:02:49 +0200 Subject: [PATCH] Rewrite generateCommits to avoid write access to commit.Parents We want to unexport Parents in a later commit. --- pkg/gui/presentation/graph/graph_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/gui/presentation/graph/graph_test.go b/pkg/gui/presentation/graph/graph_test.go index 5cb4875f5..05bf6c648 100644 --- a/pkg/gui/presentation/graph/graph_test.go +++ b/pkg/gui/presentation/graph/graph_test.go @@ -565,6 +565,7 @@ func generateCommits(count int) []*models.Commit { // I need to pick a random number of parents to add parentCount := rnd.Intn(2) + 1 + parentHashes := currentCommit.Parents for j := 0; j < parentCount; j++ { reuseParent := rnd.Intn(6) != 1 && j <= len(pool)-1 && j != 0 var newParent *models.Commit @@ -577,10 +578,15 @@ func generateCommits(count int) []*models.Commit { } pool = append(pool, newParent) } - currentCommit.Parents = append(currentCommit.Parents, newParent.Hash) + parentHashes = append(parentHashes, newParent.Hash) } - commits = append(commits, currentCommit) + changedCommit := &models.Commit{ + Hash: currentCommit.Hash, + AuthorName: currentCommit.AuthorName, + Parents: parentHashes, + } + commits = append(commits, changedCommit) } return commits