Skip to content

Commit 97aa7a0

Browse files
committed
Rewrite generateCommits to avoid write access to commit.Parents
We want to unexport Parents in a later commit.
1 parent 5844ec6 commit 97aa7a0

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pkg/gui/presentation/graph/graph_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ func generateCommits(count int) []*models.Commit {
565565
// I need to pick a random number of parents to add
566566
parentCount := rnd.Intn(2) + 1
567567

568+
parentHashes := currentCommit.Parents
568569
for j := 0; j < parentCount; j++ {
569570
reuseParent := rnd.Intn(6) != 1 && j <= len(pool)-1 && j != 0
570571
var newParent *models.Commit
@@ -577,10 +578,15 @@ func generateCommits(count int) []*models.Commit {
577578
}
578579
pool = append(pool, newParent)
579580
}
580-
currentCommit.Parents = append(currentCommit.Parents, newParent.Hash)
581+
parentHashes = append(parentHashes, newParent.Hash)
581582
}
582583

583-
commits = append(commits, currentCommit)
584+
changedCommit := &models.Commit{
585+
Hash: currentCommit.Hash,
586+
AuthorName: currentCommit.AuthorName,
587+
Parents: parentHashes,
588+
}
589+
commits = append(commits, changedCommit)
584590
}
585591

586592
return commits

0 commit comments

Comments
 (0)