diff --git a/internal/governor/governor.go b/internal/governor/governor.go index 6884525..19910f7 100644 --- a/internal/governor/governor.go +++ b/internal/governor/governor.go @@ -91,11 +91,13 @@ func update(w io.Writer, ud updateData) error { type WaitError struct { Duration time.Duration + Reason string } -func newWaitError(duration time.Duration) error { +func newWaitError(duration time.Duration, reason string) error { return WaitError{ Duration: duration, + Reason: reason, } } @@ -135,12 +137,13 @@ func schedule(r *bufio.Reader, w io.Writer, sideband io.Writer) error { //Forward message to gitrpcd sideband.Write(b) - words := strings.SplitN(line, " ", 2) + words := strings.SplitN(line, " ", 3) switch words[0] { case "continue": return nil case "wait": duration := 1 * time.Second + reason := "" if len(words) > 1 { d, err := strconv.Atoi(words[1]) if err != nil { @@ -149,11 +152,14 @@ func schedule(r *bufio.Reader, w io.Writer, sideband io.Writer) error { duration = time.Duration(d) * time.Second } } - return newWaitError(duration) + if len(words) > 2 { + reason = words[2] + } + return newWaitError(duration, reason) case "fail": reason := "UNKNOWN" if len(words) > 1 { - reason = words[1] + reason = strings.Join(words[1:], " ") } return newFailError(reason) default: