@@ -3,6 +3,7 @@ package github
3
3
import (
4
4
"fmt"
5
5
"log"
6
+ "strconv"
6
7
"strings"
7
8
8
9
ghwebhooks "github.com/go-playground/webhooks/v6/github"
@@ -15,24 +16,31 @@ func (w *Worker) processIssueComment(owner *string, pullRequest *v41.PullRequest
15
16
}
16
17
17
18
func (w * Worker ) approve (owner * string , pullRequest * v41.PullRequest , p * ghwebhooks.IssueCommentPayload ) {
18
- if strings .EqualFold (p .Comment .Body , w .Config .Layout .PullRequest .ApproveCommand ) {
19
- message := fmt .Sprintf ("[%s] Looks Good To Me!" , p .Issue .User .Login )
20
- _ , err := w .PullRequestCreateReview (* owner , p .Repository .Name , * pullRequest .Number , v41.PullRequestReviewRequest {
21
- Body : & message ,
22
- Event : v41 .String ("APPROVE" ),
23
- })
24
- if err != nil {
25
- log .Printf ("error creview: %v\n " , err )
19
+ if pullRequest != nil {
20
+ if strings .EqualFold (p .Comment .Body , w .Config .Layout .PullRequest .ApproveCommand ) {
21
+ message := fmt .Sprintf ("[%s] Looks Good To Me!" , p .Issue .User .Login )
22
+ _ , err := w .PullRequestCreateReview (* owner , p .Repository .Name , * pullRequest .Number , v41.PullRequestReviewRequest {
23
+ Body : & message ,
24
+ Event : v41 .String ("APPROVE" ),
25
+ })
26
+ if err != nil {
27
+ log .Printf ("error creview: %v\n " , err )
28
+ }
26
29
}
27
30
}
28
31
}
29
32
30
33
func (w * Worker ) reRunLaboratoryTest (owner * string , pullRequest * v41.PullRequest , p * ghwebhooks.IssueCommentPayload ) {
31
- if strings .EqualFold (p .Comment .Body , w .Config .Layout .PullRequest .ReRunTestSuiteCommand ) {
32
- w .CreateCheckRun (* owner , p .Repository .Name , v41.CreateCheckRunOptions {
33
- Name : "Laboratory test" ,
34
- Status : v41 .String ("in_progress" ),
35
- HeadSHA : * pullRequest .Head .SHA ,
36
- })
34
+ if pullRequest != nil {
35
+ if strings .EqualFold (p .Comment .Body , w .Config .Layout .PullRequest .ReRunTestSuiteCommand ) {
36
+ pullRequestNumber := strconv .Itoa (int (* pullRequest .Number ))
37
+ w .CreateCheckRun (* owner , p .Repository .Name , v41.CreateCheckRunOptions {
38
+ Name : "Laboratory test" ,
39
+ Status : v41 .String ("in_progress" ),
40
+ HeadSHA : * pullRequest .Head .SHA ,
41
+ DetailsURL : pullRequest .HTMLURL ,
42
+ ExternalID : & pullRequestNumber ,
43
+ })
44
+ }
37
45
}
38
46
}
0 commit comments