Skip to content

Commit

Permalink
wip: attempt to fix parsing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
elhmn committed Dec 18, 2023
1 parent 8bd96c5 commit 95cdc74
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions internal/governor/governor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

Expand Down Expand Up @@ -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 {
Expand All @@ -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:
Expand Down

0 comments on commit 95cdc74

Please sign in to comment.