Skip to content

Commit 569e55b

Browse files
committed
Handle new gitmon protocol
The gitmon scheduler is not able to parse the new gitmon message format that changed to `wait <delay> <reasons>\n` and `fail <delay> <reasons>\n`. This commit tries to fix that parsing.
1 parent 5b9eba9 commit 569e55b

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

internal/governor/governor.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,13 @@ func update(w io.Writer, ud updateData) error {
9292

9393
type WaitError struct {
9494
Duration time.Duration
95+
Reason string
9596
}
9697

97-
func newWaitError(duration time.Duration) error {
98+
func newWaitError(duration time.Duration, reason string) error {
9899
return WaitError{
99100
Duration: duration,
101+
Reason: reason,
100102
}
101103
}
102104

@@ -138,11 +140,13 @@ func schedule(r *bufio.Reader, w io.Writer, sideband io.Writer) error {
138140
sideband.Write(b)
139141
}
140142

143+
words := strings.SplitN(line, " ", 3)
141144
switch words[0] {
142145
case "continue":
143146
return nil
144147
case "wait":
145148
duration := 1 * time.Second
149+
reason := ""
146150
if len(words) > 1 {
147151
d, err := strconv.Atoi(words[1])
148152
if err != nil {
@@ -151,11 +155,14 @@ func schedule(r *bufio.Reader, w io.Writer, sideband io.Writer) error {
151155
duration = time.Duration(d) * time.Second
152156
}
153157
}
154-
return newWaitError(duration)
158+
if len(words) > 2 {
159+
reason = words[2]
160+
}
161+
return newWaitError(duration, reason)
155162
case "fail":
156163
reason := "UNKNOWN"
157164
if len(words) > 1 {
158-
reason = words[1]
165+
reason = strings.Join(words[1:], " ")
159166
}
160167
return newFailError(reason)
161168
default:

0 commit comments

Comments
 (0)