summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-03-20 20:12:25 +1100
committerGitHub <noreply@github.com>2023-03-20 20:12:25 +1100
commit4b67a45a16196a388216a2dee63c971e32a8ff47 (patch)
tree6a9a39aa60cdf70537d112a66a32a1eb887ce3d2
parenta82d952f482b285ece07adbaa4f1284d863054fa (diff)
parent549ce09f71e9c100ebc1a4290454362d53530e3d (diff)
Merge pull request #2515 from stefanhaller/fix-deprecated-rand-seed
-rw-r--r--pkg/gui/command_log_panel.go4
-rw-r--r--pkg/gui/presentation/graph/graph_test.go10
2 files changed, 7 insertions, 7 deletions
diff --git a/pkg/gui/command_log_panel.go b/pkg/gui/command_log_panel.go
index 859f86203..258a9cac1 100644
--- a/pkg/gui/command_log_panel.go
+++ b/pkg/gui/command_log_panel.go
@@ -191,7 +191,7 @@ func (gui *Gui) getRandomTip() string {
),
}
- rand.Seed(time.Now().UnixNano())
- randomIndex := rand.Intn(len(tips))
+ rnd := rand.New(rand.NewSource(time.Now().UnixNano()))
+ randomIndex := rnd.Intn(len(tips))
return tips[randomIndex]
}
diff --git a/pkg/gui/presentation/graph/graph_test.go b/pkg/gui/presentation/graph/graph_test.go
index a6c60acf5..27ec8652b 100644
--- a/pkg/gui/presentation/graph/graph_test.go
+++ b/pkg/gui/presentation/graph/graph_test.go
@@ -537,26 +537,26 @@ func BenchmarkRenderCommitGraph(b *testing.B) {
}
func generateCommits(count int) []*models.Commit {
- rand.Seed(1234)
+ rnd := rand.New(rand.NewSource(1234))
pool := []*models.Commit{{Sha: "a", AuthorName: "A"}}
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"}
for len(commits) < count {
- currentCommitIdx := rand.Intn(len(pool))
+ currentCommitIdx := rnd.Intn(len(pool))
currentCommit := pool[currentCommitIdx]
pool = append(pool[0:currentCommitIdx], pool[currentCommitIdx+1:]...)
// 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++ {
- 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
if reuseParent {
newParent = pool[j]
} else {
newParent = &models.Commit{
Sha: fmt.Sprintf("%s%d", currentCommit.Sha, j),
- AuthorName: authorPool[rand.Intn(len(authorPool))],
+ AuthorName: authorPool[rnd.Intn(len(authorPool))],
}
pool = append(pool, newParent)
}