Commit 90cdc51 1 parent 69af6e2 commit 90cdc51 Copy full SHA for 90cdc51
File tree 3 files changed +22
-0
lines changed
contribs/github-bot/internal
3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -36,10 +36,21 @@ func deduplicateReviews(reviews []*github.PullRequestReview) []*github.PullReque
36
36
result = append (result , rev )
37
37
added [rev .User .GetLogin ()] = len (result ) - 1
38
38
}
39
+ case utils .ReviewStateDismissed :
40
+ // this state just dismisses any previous review, so remove previous
41
+ // entry for this user if it exists.
42
+ if ok {
43
+ result [idx ] = nil
44
+ }
39
45
default :
40
46
panic (fmt .Sprintf ("invalid review state %q" , rev .GetState ()))
41
47
}
42
48
}
49
+ // Remove nil entries from the result (dismissed reviews).
50
+ result = slices .DeleteFunc (result , func (r * github.PullRequestReview ) bool {
51
+ return r == nil
52
+ })
53
+
43
54
return result
44
55
}
45
56
Original file line number Diff line number Diff line change @@ -68,6 +68,16 @@ func Test_deduplicateReviews(t *testing.T) {
68
68
{User : & github.User {Login : github .String ("userB" )}, State : github .String ("CHANGES_REQUESTED" )},
69
69
},
70
70
},
71
+ {
72
+ name : "two authors - approval/changes requested then dismissed" ,
73
+ reviews : []* github.PullRequestReview {
74
+ {User : & github.User {Login : github .String ("user1" )}, State : github .String ("APPROVED" )},
75
+ {User : & github.User {Login : github .String ("user1" )}, State : github .String ("DISMISSED" )},
76
+ {User : & github.User {Login : github .String ("user2" )}, State : github .String ("CHANGES_REQUESTED" )},
77
+ {User : & github.User {Login : github .String ("user2" )}, State : github .String ("DISMISSED" )},
78
+ },
79
+ expected : []* github.PullRequestReview {},
80
+ },
71
81
}
72
82
73
83
for _ , tt := range tests {
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ const (
23
23
ReviewStateApproved ReviewState = "APPROVED"
24
24
ReviewStateChangesRequested ReviewState = "CHANGES_REQUESTED"
25
25
ReviewStateCommented ReviewState = "COMMENTED"
26
+ ReviewStateDismissed ReviewState = "DISMISSED"
26
27
)
27
28
28
29
// Valid determines whether the ReviewState is one of the known ReviewStates.
You can’t perform that action at this time.
0 commit comments