mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 04:15:48 +02:00
Merge pull request #2515 from stefanhaller/fix-deprecated-rand-seed
This commit is contained in:
commit
4b67a45a16
2 changed files with 7 additions and 7 deletions
|
@ -191,7 +191,7 @@ func (gui *Gui) getRandomTip() string {
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
rand.Seed(time.Now().UnixNano())
|
rnd := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||||
randomIndex := rand.Intn(len(tips))
|
randomIndex := rnd.Intn(len(tips))
|
||||||
return tips[randomIndex]
|
return tips[randomIndex]
|
||||||
}
|
}
|
||||||
|
|
|
@ -537,26 +537,26 @@ func BenchmarkRenderCommitGraph(b *testing.B) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateCommits(count int) []*models.Commit {
|
func generateCommits(count int) []*models.Commit {
|
||||||
rand.Seed(1234)
|
rnd := rand.New(rand.NewSource(1234))
|
||||||
pool := []*models.Commit{{Sha: "a", AuthorName: "A"}}
|
pool := []*models.Commit{{Sha: "a", AuthorName: "A"}}
|
||||||
commits := make([]*models.Commit, 0, count)
|
commits := make([]*models.Commit, 0, count)
|
||||||
authorPool := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
|
authorPool := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
|
||||||
for len(commits) < count {
|
for len(commits) < count {
|
||||||
currentCommitIdx := rand.Intn(len(pool))
|
currentCommitIdx := rnd.Intn(len(pool))
|
||||||
currentCommit := pool[currentCommitIdx]
|
currentCommit := pool[currentCommitIdx]
|
||||||
pool = append(pool[0:currentCommitIdx], pool[currentCommitIdx+1:]...)
|
pool = append(pool[0:currentCommitIdx], pool[currentCommitIdx+1:]...)
|
||||||
// I need to pick a random number of parents to add
|
// I need to pick a random number of parents to add
|
||||||
parentCount := rand.Intn(2) + 1
|
parentCount := rnd.Intn(2) + 1
|
||||||
|
|
||||||
for j := 0; j < parentCount; j++ {
|
for j := 0; j < parentCount; j++ {
|
||||||
reuseParent := rand.Intn(6) != 1 && j <= len(pool)-1 && j != 0
|
reuseParent := rnd.Intn(6) != 1 && j <= len(pool)-1 && j != 0
|
||||||
var newParent *models.Commit
|
var newParent *models.Commit
|
||||||
if reuseParent {
|
if reuseParent {
|
||||||
newParent = pool[j]
|
newParent = pool[j]
|
||||||
} else {
|
} else {
|
||||||
newParent = &models.Commit{
|
newParent = &models.Commit{
|
||||||
Sha: fmt.Sprintf("%s%d", currentCommit.Sha, j),
|
Sha: fmt.Sprintf("%s%d", currentCommit.Sha, j),
|
||||||
AuthorName: authorPool[rand.Intn(len(authorPool))],
|
AuthorName: authorPool[rnd.Intn(len(authorPool))],
|
||||||
}
|
}
|
||||||
pool = append(pool, newParent)
|
pool = append(pool, newParent)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue