Skip to content

Commit c466689

Browse files
authored
Merge pull request #204 from Centril/various-improvements
Fix #201 (Controllable auto-close/postpone behavior)
2 parents 806c01c + 4451cf9 commit c466689

File tree

5 files changed

+252
-83
lines changed

5 files changed

+252
-83
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ target
66
*.log
77
.envrc
88
*~
9+
rls/

teams.toml rfcbot.toml

+22-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1-
[T-core]
1+
[fcp_behaviors]
2+
3+
[fcp_behaviors."rust-lang/rfcs"]
4+
close = true
5+
postpone = true
6+
7+
[fcp_behaviors."rust-lang/rust"]
8+
close = false
9+
postpone = false
10+
11+
[teams]
12+
13+
[teams.T-core]
214
name = "Core"
315
ping = "rust-lang/core"
416
members = [
@@ -14,7 +26,7 @@ members = [
1426
"Mark-Simulacrum",
1527
]
1628

17-
[T-lang]
29+
[teams.T-lang]
1830
name = "Language"
1931
ping = "rust-lang/lang"
2032
members = [
@@ -29,7 +41,7 @@ members = [
2941
"scottmcm",
3042
]
3143

32-
[T-libs]
44+
[teams.T-libs]
3345
name = "Libraries"
3446
ping = "rust-lang/libs"
3547
members = [
@@ -42,7 +54,7 @@ members = [
4254
"SimonSapin",
4355
]
4456

45-
[T-compiler]
57+
[teams.T-compiler]
4658
name = "Compiler"
4759
ping = "rust-lang/compiler"
4860
members = [
@@ -59,7 +71,7 @@ members = [
5971
"oli-obk",
6072
]
6173

62-
[T-doc]
74+
[teams.T-doc]
6375
name = "Documentation"
6476
ping = "rust-lang/docs"
6577
members = [
@@ -69,7 +81,7 @@ members = [
6981
"steveklabnik",
7082
]
7183

72-
[T-infra]
84+
[teams.T-infra]
7385
name = "Infrastructure"
7486
ping = "rust-lang/infra"
7587
members = [
@@ -84,7 +96,7 @@ members = [
8496
"TimNN",
8597
]
8698

87-
[T-cargo]
99+
[teams.T-cargo]
88100
name = "Cargo"
89101
ping = "rust-lang/cargo"
90102
members = [
@@ -97,7 +109,7 @@ members = [
97109
"wycats",
98110
]
99111

100-
[T-dev-tools]
112+
[teams.T-dev-tools]
101113
name = "Dev tools"
102114
ping = "rust-lang/dev-tools"
103115
members = [
@@ -110,7 +122,7 @@ members = [
110122
"steveklabnik",
111123
]
112124

113-
[T-dev-tools-rustdoc]
125+
[teams.T-dev-tools-rustdoc]
114126
name = "Rustdoc"
115127
ping = "rust-lang/rustdoc"
116128
members = [
@@ -121,7 +133,7 @@ members = [
121133
"steveklabnik",
122134
]
123135

124-
[T-IDEs]
136+
[teams.T-IDEs]
125137
name = "IDEs and editors"
126138
ping = "rust-lang/IDEs"
127139
members = [

src/github/nag.rs

+23-21
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use domain::rfcbot::{FcpConcern, FcpProposal, FcpReviewRequest, FeedbackRequest,
1414
use domain::schema::*;
1515
use error::*;
1616
use github::models::CommentFromJson;
17-
use teams::TEAMS;
17+
use teams::SETUP;
1818
use super::GH;
1919

2020
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
@@ -464,24 +464,31 @@ fn evaluate_nags() -> DashResult<()> {
464464
Ok(())
465465
}
466466

467-
fn execute_ffcp_actions(issue: &Issue, disposition: FcpDisposition) {
468-
if !is_rfc_repo(&issue) { return; }
467+
fn can_ffcp_close(issue: &Issue) -> bool {
468+
SETUP.should_ffcp_auto_close(&issue.repository)
469+
}
470+
471+
fn can_ffcp_postpone(issue: &Issue) -> bool {
472+
SETUP.should_ffcp_auto_postpone(&issue.repository)
473+
}
469474

475+
fn execute_ffcp_actions(issue: &Issue, disposition: FcpDisposition) {
470476
match disposition {
471477
FcpDisposition::Merge => {
472478
// TODO: This one will require a lot of work to
473479
// auto-merge RFCs and create the tracking issue.
474480
},
475-
FcpDisposition::Close => {
481+
FcpDisposition::Close if can_ffcp_close(issue) => {
476482
let _ = issue.add_label(Label::Closed);
477483
issue.remove_label(Label::DispositionClose);
478484
issue.close();
479485
},
480-
FcpDisposition::Postpone => {
486+
FcpDisposition::Postpone if can_ffcp_postpone(issue) => {
481487
let _ = issue.add_label(Label::Postponed);
482488
issue.remove_label(Label::DispositionPostpone);
483489
issue.close();
484490
},
491+
_ => {},
485492
}
486493
}
487494

@@ -566,9 +573,9 @@ fn subteam_members(issue: &Issue) -> DashResult<Vec<GitHubUser>> {
566573

567574
// retrieve all of the teams tagged on this issue
568575
// cannot WAIT for by-ref/by-val inference
569-
let member_logins = TEAMS.iter()
576+
let member_logins = SETUP.teams()
570577
.filter(|&(ref label, _)| issue.labels.contains(&label.0))
571-
.flat_map(|(_, team)| &team.member_logins)
578+
.flat_map(|(_, team)| team.member_logins())
572579
.collect::<BTreeSet<_>>()
573580
.into_iter() // diesel won't work with btreeset, and dedup has weird lifetime errors
574581
.collect::<Vec<_>>();
@@ -1028,10 +1035,6 @@ enum CommentType<'a> {
10281035
},
10291036
}
10301037

1031-
fn is_rfc_repo(issue: &Issue) -> bool {
1032-
issue.repository == "rust-lang/rfcs"
1033-
}
1034-
10351038
impl<'a> RfcBotComment<'a> {
10361039
fn new(issue: &'a Issue, comment_type: CommentType<'a>) -> RfcBotComment<'a> {
10371040

@@ -1146,16 +1149,15 @@ impl<'a> RfcBotComment<'a> {
11461149
Self::add_comment_url(issue, &mut msg, status_comment_id);
11471150
msg.push_str("), is now **complete**.");
11481151

1149-
if is_rfc_repo(issue) {
1150-
match disposition {
1151-
FcpDisposition::Merge => {}
1152-
FcpDisposition::Close => {
1153-
msg.push_str("\n\nBy the power vested in me by Rust, I hereby close this RFC.");
1154-
},
1155-
FcpDisposition::Postpone => {
1156-
msg.push_str("\n\nBy the power vested in me by Rust, I hereby postpone this RFC.");
1157-
},
1158-
}
1152+
match disposition {
1153+
FcpDisposition::Merge => {}
1154+
FcpDisposition::Close if can_ffcp_close(issue) => {
1155+
msg.push_str("\n\nBy the power vested in me by Rust, I hereby close this RFC.");
1156+
},
1157+
FcpDisposition::Postpone if can_ffcp_postpone(issue) => {
1158+
msg.push_str("\n\nBy the power vested in me by Rust, I hereby postpone this RFC.");
1159+
},
1160+
_ => {},
11591161
}
11601162

11611163
if !added_label {

src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ fn main() {
7272
let _ = DB_POOL.get().expect("Unable to test connection pool.");
7373

7474
// we want to panic if we're unable to find any of the usernames
75-
let parsed_teams = teams::TEAMS.keys().collect::<Vec<_>>();
75+
let parsed_teams = teams::SETUP.team_labels().collect::<Vec<_>>();
7676
info!("parsed teams: {:?}", parsed_teams);
7777

7878
// FIXME(anp) need to handle panics in both the listeners and crash the server

0 commit comments

Comments
 (0)