1
- use crate :: db:: issue_data:: IssueData ;
2
1
use crate :: {
3
2
config:: AutolabelConfig ,
4
3
github:: { IssuesAction , IssuesEvent , Label } ,
@@ -7,16 +6,6 @@ use crate::{
7
6
use anyhow:: Context as _;
8
7
use tracing as log;
9
8
10
- /// Key for the state in the database
11
- const AUTOLABEL_KEY : & str = "autolabel" ;
12
-
13
- /// State stored in the database
14
- #[ derive( Debug , Default , PartialEq , Clone , serde:: Deserialize , serde:: Serialize ) ]
15
- struct AutolabelState {
16
- /// If true, then `autolabel.new_pr` labels have already been applied to this PR.
17
- new_pr_labels_applied : bool ,
18
- }
19
-
20
9
pub ( super ) struct AutolabelInput {
21
10
add : Vec < Label > ,
22
11
remove : Vec < Label > ,
@@ -44,12 +33,6 @@ pub(super) async fn parse_input(
44
33
| IssuesAction :: ReadyForReview
45
34
| IssuesAction :: ConvertedToDraft
46
35
) {
47
- let mut db = ctx. db . get ( ) . await ;
48
- let mut state: IssueData < ' _ , AutolabelState > =
49
- IssueData :: load ( & mut db, & event. issue , AUTOLABEL_KEY )
50
- . await
51
- . map_err ( |e| e. to_string ( ) ) ?;
52
-
53
36
let files = event
54
37
. issue
55
38
. diff ( & ctx. github )
@@ -102,24 +85,21 @@ pub(super) async fn parse_input(
102
85
103
86
// Treat the following situations as a "new PR":
104
87
// 1) New PRs opened as non-draft
105
- // 2) PRs opened as draft that are marked as "ready for review" for the first time .
88
+ // 2) PRs opened as draft that are marked as "ready for review".
106
89
let is_new_non_draft_pr =
107
90
event. action == IssuesAction :: Opened && !event. issue . draft ;
108
- let is_first_time_ready_for_review = event. action == IssuesAction :: ReadyForReview
109
- && !state. data . new_pr_labels_applied ;
110
- if cfg. new_pr && ( is_new_non_draft_pr || is_first_time_ready_for_review) {
91
+ let is_ready_for_review = event. action == IssuesAction :: ReadyForReview ;
92
+ if cfg. new_pr && ( is_new_non_draft_pr || is_ready_for_review) {
111
93
autolabels. push ( Label {
112
94
name : label. to_owned ( ) ,
113
95
} ) ;
114
- state. data . new_pr_labels_applied = true ;
115
96
}
116
97
117
98
// If a PR is converted to draft remove all the "new PR" labels
118
99
if cfg. new_pr && event. action == IssuesAction :: ConvertedToDraft {
119
100
to_remove. push ( Label {
120
101
name : label. to_owned ( ) ,
121
102
} ) ;
122
- state. data . new_pr_labels_applied = false ;
123
103
}
124
104
} else {
125
105
if cfg. new_issue && event. action == IssuesAction :: Opened {
@@ -130,8 +110,6 @@ pub(super) async fn parse_input(
130
110
}
131
111
}
132
112
133
- state. save ( ) . await . map_err ( |e| e. to_string ( ) ) ?;
134
-
135
113
if !autolabels. is_empty ( ) || !to_remove. is_empty ( ) {
136
114
return Ok ( Some ( AutolabelInput {
137
115
add : autolabels,
0 commit comments