Skip to content

Commit

Permalink
Print newline on feedback if not already present
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
alexellis committed Apr 6, 2022
1 parent 00516ba commit 0ef9a3d
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions handler/comment_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,37 +72,24 @@ func HandleComment(req types.IssueCommentOuter, config config.Config, derekConfi
switch command.Type {

case addLabelConstant, removeLabelConstant:

feedback, err = manageLabel(req, command.Type, command.Value, config)
break

case assignConstant, unassignConstant:

feedback, err = manageAssignment(req, command.Type, command.Value, config)
break

case closeConstant, reopenConstant:

feedback, err = manageState(req, command.Type, config)
break

case setTitleConstant:

feedback, err = manageTitle(req, command.Type, command.Value, config)
break

case lockConstant, unlockConstant:

feedback, err = manageLocking(req, command.Type, config)
break

case setMilestoneConstant, removeMilestoneConstant:

feedback, err = updateMilestone(req, command.Type, command.Value, config)
break

case assignReviewerConstant, unassignReviewerConstant:

pr := types.PullRequest{
Number: req.Issue.Number,
}
Expand All @@ -113,22 +100,22 @@ func HandleComment(req types.IssueCommentOuter, config config.Config, derekConfi
InstallationRequest: req.InstallationRequest,
}
feedback, err = editReviewers(prReq, command.Type, command.Value, config)
break

case messageConstant:

feedback, err = createMessage(req, command.Type, command.Value, config, derekConfig)
break

default:
feedback = "No command found in comment"
feedback = "No command found in comment\n"

if strings.HasPrefix(req.Comment.Body, "Derek ") || strings.HasPrefix(req.Comment.Body, "/") {
feedback = fmt.Sprintf("Unable to work with command: %q", req.Comment.Body)
feedback = fmt.Sprintf("Unable to work with command: %q\n", req.Comment.Body)
}

err = nil
break
}

if !strings.HasSuffix(feedback, "\n") {
feedback += "\n"
}

fmt.Print(feedback)
Expand Down

0 comments on commit 0ef9a3d

Please sign in to comment.