MCPcopy Create free account
hub / github.com/git-bug/git-bug / generateRandomBugsWithSeed

Function generateRandomBugsWithSeed

misc/random_bugs/create_random_bugs.go:61–113  ·  view source on GitHub ↗
(opts Options, seed int64)

Source from the content-addressed store, hash-verified

59}
60
61func generateRandomBugsWithSeed(opts Options, seed int64) []*bug.Bug {
62 rand.Seed(seed)
63 fake.Seed(seed)
64
65 // At the moment git-bug has a risk of hash collision is simple
66 // operation (like open/close) are made with the same timestamp.
67 // As a temporary workaround, we use here an strictly increasing
68 // timestamp
69 timestamp := time.Now().Unix()
70
71 opsGenerators := []opsGenerator{
72 comment,
73 comment,
74 title,
75 labels,
76 open,
77 close,
78 }
79
80 result := make([]*bug.Bug, opts.BugNumber)
81
82 for i := 0; i < opts.BugNumber; i++ {
83 addedLabels = []string{}
84
85 b, _, err := bug.Create(
86 randomPerson(),
87 time.Now().Unix(),
88 fake.Sentence(),
89 paragraphs(),
90 nil, nil,
91 )
92
93 if err != nil {
94 panic(err)
95 }
96
97 nOps := opts.MinOp
98
99 if opts.MaxOp > opts.MinOp {
100 nOps += rand.Intn(opts.MaxOp - opts.MinOp)
101 }
102
103 for j := 0; j < nOps; j++ {
104 index := rand.Intn(len(opsGenerators))
105 opsGenerators[index](b, randomPerson(), timestamp)
106 timestamp++
107 }
108
109 result[i] = b
110 }
111
112 return result
113}
114
115func person(repo repository.RepoClock) (*identity.Identity, error) {
116 return identity.NewIdentity(repo, fake.FullName(), fake.EmailAddress())

Callers 1

CommitRandomBugsWithSeedFunction · 0.85

Calls 3

CreateFunction · 0.92
randomPersonFunction · 0.85
paragraphsFunction · 0.85

Tested by

no test coverage detected