mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-10 20:05:50 +02:00
Rewrite generateCommits to avoid write access to commit.Parents
We want to unexport Parents in a later commit.
This commit is contained in:
parent
5844ec6eb2
commit
97aa7a04e6
1 changed files with 8 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue