Skip to content
Merged
Changes from 1 commit
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
10 changes: 6 additions & 4 deletions tool/actions-plan-preview/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ func main() {
}

if event.PRClosed {
doComment(failureBadgeURL + "Unable to run plan-preview for a closed pull request.")
doComment(failureBadgeURL + "\nUnable to run plan-preview for a closed pull request.")
return
}

// TODO: When PR opened, `Mergeable` is nil for calculation.
// Here it is not considered for now, but needs to be handled.
if event.PRMergeable != nil && *event.PRMergeable == false {
doComment(failureBadgeURL + "Unable to run plan-preview for an un-mergeable pull request. Please resolve the conficts and try again.")
doComment(failureBadgeURL + "\nUnable to run plan-preview for an un-mergeable pull request. Please resolve the conficts and try again.")
return
}

Expand All @@ -123,6 +123,7 @@ func main() {
args.Timeout,
)
if err != nil {
doComment(failureBadgeURL + "\nUnable to run plan-preview. \ncause: " + err.Error())
log.Fatal(err)
}
log.Println("Successfully retrieved plan-preview result")
Expand All @@ -131,10 +132,11 @@ func main() {
if result.HasError() {
pr, err := getPullRequest(ctx, ghClient.PullRequests, event.Owner, event.Repo, event.PRNumber)
if err != nil {
doComment(failureBadgeURL + "\nUnable to run plan-preview. \ncause: " + err.Error())
log.Fatal(err)
}
if !pr.GetClosedAt().IsZero() {
doComment(failureBadgeURL + "Unable to run plan-preview for a closed pull request.")
doComment(failureBadgeURL + "\nUnable to run plan-preview for a closed pull request.")
return
}
}
Expand All @@ -152,7 +154,7 @@ func main() {
return
}

if bool(comment.IsMinimized) {
if comment.IsMinimized {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this cast is to ensure we can notice if the lib type Boolean changed, so let's keep it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I see your point👍

@TakumaKurosawa TakumaKurosawa Nov 9, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@khanhtc1202
Applied!!
5aded83

log.Printf("Previous plan-preview comment has already minimized. So don't minimize anything\n")
return
}
Expand Down