Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: prepare release #724

Merged
merged 5 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions plugins/aladino/actions/review.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,21 @@ func reviewCode(e aladino.Env, args []aladino.Value) error {
}

if latestReview != nil {
// The last push was made before the last review so a new review is not needed
if lastPushDate.Before(*latestReview.SubmittedAt) {
log.Infof("skipping review because there were no updates since the last review")
return nil
}

latestReviewEvent, err := mapReviewStateToEvent(latestReview.State)
if err != nil {
return err
}

// If the latest review is the same as the one we want to create, and the last push date is before the latest review
// then we skip the review creation.
if latestReview.State == reviewEvent && latestReview.Body == reviewBody && lastPushDate.Before(*latestReview.SubmittedAt) {
Copy link
Contributor

@zolamk zolamk Feb 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition will never be true because we are not comparing the mapped state to the event right

Suggested change
if latestReview.State == reviewEvent && latestReview.Body == reviewBody && lastPushDate.Before(*latestReview.SubmittedAt) {
if latestReviewEvent == reviewEvent && latestReview.Body == reviewBody && lastPushDate.Before(*latestReview.SubmittedAt) {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using latestReviewEvent which is a result from mapReviewStateToEvent(latestReview.State). Isn't this what you're saying?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I already pushed a fix for this review 😅 , just wanted to leave the reason for the change here, it should be like that right

log.Infof("skipping review because there were no updates since the last review")
return nil
}

log.Infof("latest review from %v is %v with body %v", authenticatedUserLogin, latestReviewEvent, latestReview.Body)
}

log.Infof("creating review %v with body %v", reviewEvent, reviewBody)

return t.Review(reviewEvent, reviewBody)
Expand Down
8 changes: 6 additions & 2 deletions runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,13 @@ func Run(
command := eventDetails.Payload.(*github.IssueCommentEvent).GetComment().GetBody()
if utils.IsReviewpadCommandDryRun(command) {
return runReviewpadCommandDryRun(log, collector, gitHubClient, targetEntity, reviewpadFile, env)
} else {
return runReviewpadCommand(ctx, log, collector, gitHubClient, targetEntity, env, aladinoInterpreter, command)
}

if utils.IsReviewpadCommandRun(command) {
return runReviewpadFile(log, collector, gitHubClient, targetEntity, eventDetails, reviewpadFile, dryRun, safeMode, env, aladinoInterpreter)
}

return runReviewpadCommand(ctx, log, collector, gitHubClient, targetEntity, env, aladinoInterpreter, command)
} else {
return runReviewpadFile(log, collector, gitHubClient, targetEntity, eventDetails, reviewpadFile, dryRun, safeMode, env, aladinoInterpreter)
}
Expand Down
4 changes: 4 additions & 0 deletions utils/pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ func IsReviewpadCommand(eventDetails *handler.EventDetails) bool {
func IsReviewpadCommandDryRun(command string) bool {
return strings.TrimPrefix(command, "/reviewpad ") == "dry-run"
}

func IsReviewpadCommandRun(command string) bool {
return strings.TrimPrefix(command, "/reviewpad ") == "run"
}