21
21
//! the PR modifies.
22
22
23
23
use crate :: {
24
- config:: { AssignConfig , WarnNonDefaultBranchException } ,
24
+ config:: AssignConfig ,
25
25
github:: { self , Event , FileDiff , Issue , IssuesAction , Selection } ,
26
26
handlers:: { Context , GithubClient , IssuesEvent } ,
27
27
interactions:: EditIssueBody ,
@@ -74,18 +74,6 @@ const ON_VACATION_WARNING: &str = "{username} is on vacation.
74
74
75
75
Please choose another assignee." ;
76
76
77
- const NON_DEFAULT_BRANCH : & str =
78
- "Pull requests are usually filed against the {default} branch for this repo, \
79
- but this one is against {target}. \
80
- Please double check that you specified the right target!";
81
-
82
- const NON_DEFAULT_BRANCH_EXCEPTION : & str =
83
- "Pull requests targetting the {default} branch are usually filed against the {default} \
84
- branch, but this one is against {target}. \
85
- Please double check that you specified the right target!";
86
-
87
- const SUBMODULE_WARNING_MSG : & str = "These commits modify **submodules**." ;
88
-
89
77
pub const SELF_ASSIGN_HAS_NO_CAPACITY : & str = "
90
78
You have insufficient capacity to be assigned the pull request at this time. PR assignment has been reverted.
91
79
@@ -218,20 +206,6 @@ pub(super) async fn handle_input(
218
206
}
219
207
}
220
208
221
- // Compute some warning messages to post to new PRs.
222
- let mut warnings = Vec :: new ( ) ;
223
- if let Some ( exceptions) = config. warn_non_default_branch . enabled_and_exceptions ( ) {
224
- warnings. extend ( non_default_branch ( exceptions, event) ) ;
225
- }
226
- warnings. extend ( modifies_submodule ( diff) ) ;
227
- if !warnings. is_empty ( ) {
228
- let warnings: Vec < _ > = warnings
229
- . iter ( )
230
- . map ( |warning| format ! ( "* {warning}" ) )
231
- . collect ( ) ;
232
- let warning = format ! ( ":warning: **Warning** :warning:\n \n {}" , warnings. join( "\n " ) ) ;
233
- event. issue . post_comment ( & ctx. github , & warning) . await ?;
234
- } ;
235
209
Ok ( ( ) )
236
210
}
237
211
@@ -250,40 +224,6 @@ fn is_self_assign(assignee: &str, pr_author: &str) -> bool {
250
224
assignee. to_lowercase ( ) == pr_author. to_lowercase ( )
251
225
}
252
226
253
- /// Returns a message if the PR is opened against the non-default branch (or the exception branch
254
- /// if it's an exception).
255
- fn non_default_branch (
256
- exceptions : & [ WarnNonDefaultBranchException ] ,
257
- event : & IssuesEvent ,
258
- ) -> Option < String > {
259
- let target_branch = & event. issue . base . as_ref ( ) . unwrap ( ) . git_ref ;
260
- let ( default_branch, warn_msg) = exceptions
261
- . iter ( )
262
- . find ( |e| event. issue . title . contains ( & e. title ) )
263
- . map_or_else (
264
- || ( & event. repository . default_branch , NON_DEFAULT_BRANCH ) ,
265
- |e| ( & e. branch , NON_DEFAULT_BRANCH_EXCEPTION ) ,
266
- ) ;
267
- if target_branch == default_branch {
268
- return None ;
269
- }
270
- Some (
271
- warn_msg
272
- . replace ( "{default}" , default_branch)
273
- . replace ( "{target}" , target_branch) ,
274
- )
275
- }
276
-
277
- /// Returns a message if the PR modifies a git submodule.
278
- fn modifies_submodule ( diff : & [ FileDiff ] ) -> Option < String > {
279
- let re = regex:: Regex :: new ( r"\+Subproject\scommit\s" ) . unwrap ( ) ;
280
- if diff. iter ( ) . any ( |fd| re. is_match ( & fd. diff ) ) {
281
- Some ( SUBMODULE_WARNING_MSG . to_string ( ) )
282
- } else {
283
- None
284
- }
285
- }
286
-
287
227
/// Sets the assignee of a PR, alerting any errors.
288
228
async fn set_assignee ( issue : & Issue , github : & GithubClient , username : & str ) {
289
229
// Don't re-assign if already assigned, e.g. on comment edit
0 commit comments