Skip to content

Commit 95cdc74

Browse files
committed
wip: attempt to fix parsing errors
1 parent 8bd96c5 commit 95cdc74

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

internal/governor/governor.go

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

9292
type WaitError struct {
9393
Duration time.Duration
94+
Reason string
9495
}
9596

96-
func newWaitError(duration time.Duration) error {
97+
func newWaitError(duration time.Duration, reason string) error {
9798
return WaitError{
9899
Duration: duration,
100+
Reason: reason,
99101
}
100102
}
101103

@@ -135,12 +137,13 @@ func schedule(r *bufio.Reader, w io.Writer, sideband io.Writer) error {
135137
//Forward message to gitrpcd
136138
sideband.Write(b)
137139

138-
words := strings.SplitN(line, " ", 2)
140+
words := strings.SplitN(line, " ", 3)
139141
switch words[0] {
140142
case "continue":
141143
return nil
142144
case "wait":
143145
duration := 1 * time.Second
146+
reason := ""
144147
if len(words) > 1 {
145148
d, err := strconv.Atoi(words[1])
146149
if err != nil {
@@ -149,11 +152,14 @@ func schedule(r *bufio.Reader, w io.Writer, sideband io.Writer) error {
149152
duration = time.Duration(d) * time.Second
150153
}
151154
}
152-
return newWaitError(duration)
155+
if len(words) > 2 {
156+
reason = words[2]
157+
}
158+
return newWaitError(duration, reason)
153159
case "fail":
154160
reason := "UNKNOWN"
155161
if len(words) > 1 {
156-
reason = words[1]
162+
reason = strings.Join(words[1:], " ")
157163
}
158164
return newFailError(reason)
159165
default:

0 commit comments

Comments
 (0)