MCPcopy Index your code
hub / github.com/git-bug/git-bug / CacheBuildProgressBar

Function CacheBuildProgressBar

commands/execenv/loading.go:133–173  ·  view source on GitHub ↗
(env *Env, events chan cache.BuildEvent)

Source from the content-addressed store, hash-verified

131}
132
133func CacheBuildProgressBar(env *Env, events chan cache.BuildEvent) error {
134 var progress *mpb.Progress
135 var bars = make(map[string]*mpb.Bar)
136
137 for event := range events {
138 if event.Err != nil {
139 return event.Err
140 }
141
142 if progress == nil {
143 progress = mpb.New(mpb.WithOutput(env.Err.Raw()))
144 }
145
146 switch event.Event {
147 case cache.BuildEventCacheIsBuilt:
148 env.Err.Println("Building cache... ")
149 case cache.BuildEventStarted:
150 bars[event.Typename] = progress.AddBar(-1,
151 mpb.BarRemoveOnComplete(),
152 mpb.PrependDecorators(
153 decor.Name(event.Typename, decor.WCSyncSpace),
154 decor.CountersNoUnit("%d / %d", decor.WCSyncSpace),
155 ),
156 mpb.AppendDecorators(decor.Percentage(decor.WCSyncSpace)),
157 )
158 case cache.BuildEventProgress:
159 bars[event.Typename].SetCurrent(event.Progress)
160 bars[event.Typename].SetTotal(event.Total, event.Progress == event.Total)
161 case cache.BuildEventFinished:
162 if bar := bars[event.Typename]; !bar.Completed() {
163 bar.SetTotal(0, true)
164 }
165 }
166 }
167
168 if progress != nil {
169 progress.Wait()
170 }
171
172 return nil
173}

Callers 2

runWebUIFunction · 0.92
LoadBackendFunction · 0.85

Calls 5

WaitMethod · 0.80
RawMethod · 0.65
PrintlnMethod · 0.65
NameMethod · 0.65
NewMethod · 0.45

Tested by

no test coverage detected