blob: a814c4769b6f3ece0f6d283cc5f8df41b7fcb228 (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
package gui
import (
"github.com/isacikgoz/gitbatch/pkg/git"
"github.com/jroimartin/gocui"
log "github.com/sirupsen/logrus"
)
// this function starts the queue and updates the gui with the result of an
// operation
func (gui *Gui) startQueue(g *gocui.Gui, v *gocui.View) error {
go func(gui_go *Gui, g_go *gocui.Gui) {
for {
job, finished, err := gui_go.State.Queue.StartNext()
// for each job execution we better refresh the main
// it would be nice if we can also refresh side views
g_go.Update(func(gu *gocui.Gui) error {
gui_go.refreshMain(gu)
return nil
})
if err != nil {
if err == git.ErrAuthenticationRequired {
// pause the job, so it will be indicated to being blocking
job.Entity.State = git.Paused
err := gui_go.openAuthenticationView(g, gui_go.State.Queue, job, v.Name())
if err != nil {
log.Warn(err.Error())
return
}
}
return
// with not returning here, we simply ignore and continue
}
// if queue is finished simply return from this goroutine
if finished {
return
}
selectedEntity := gui_go.getSelectedRepository()
if job.Entity == selectedEntity {
gui_go.refreshViews(g, job.Entity)
}
}
}(gui, g)
return nil
}
// flashes the keybinding view's backgroun with green color to indicate that
// the queue is started
func indicateQueueStarted(g *gocui.Gui) error {
v, err := g.View(keybindingsViewFeature.Name)
if err != nil {
return err
}
v.BgColor = gocui.ColorGreen
v.FgColor = gocui.ColorBlack
return nil
}
|