Skip to content

Commit fddcc0b

Browse files
committed
Adding initiator to FCP comments.
Set the proposer of an FCP to "reviewed" automatically. Accept the pr command as an alias to fcp but don't do anything with it yet. Update the text of the status message to reflect the process better.
1 parent c410095 commit fddcc0b

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

src/github/nag.rs

+27-10
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ fn evaluate_nags() -> DashResult<()> {
110110
let pending_proposals = fcp_proposal.filter(fcp_start.is_null()).load::<FcpProposal>(conn)?;
111111

112112
for mut proposal in pending_proposals {
113+
let initiator = githubuser::table.find(proposal.fk_initiator).first::<GitHubUser>(conn)?;
113114
let issue = issue::table.find(proposal.fk_issue).first::<Issue>(conn)?;
114115

115116
// check to see if any checkboxes were modified before we end up replacing the comment
@@ -125,6 +126,7 @@ fn evaluate_nags() -> DashResult<()> {
125126

126127
// update existing status comment with reviews & concerns
127128
let status_comment = RfcBotComment::new(&issue, CommentType::FcpProposed(
129+
&initiator,
128130
FcpDisposition::from_str(&proposal.disposition)?,
129131
&reviews,
130132
&concerns));
@@ -136,6 +138,8 @@ fn evaluate_nags() -> DashResult<()> {
136138
proposal.fcp_start = Some(UTC::now().naive_utc());
137139
diesel::update(fcp_proposal.find(proposal.id)).set(&proposal).execute(conn)?;
138140

141+
// TODO attempt to add the final-comment-period label
142+
139143
// leave a comment for FCP start
140144
let fcp_start_comment = RfcBotComment::new(&issue,
141145
CommentType::FcpAllReviewedNoConcerns);
@@ -322,8 +326,8 @@ impl<'a> RfcBotCommand<'a> {
322326
info!("proposal is a new FCP, creating...");
323327

324328
// leave github comment stating that FCP is proposed, ping reviewers
325-
let gh_comment = RfcBotComment::new(issue,
326-
CommentType::FcpProposed(disp, &[], &[]));
329+
let gh_comment =
330+
RfcBotComment::new(issue, CommentType::FcpProposed(author, disp, &[], &[]));
327331

328332
let gh_comment = gh_comment.post(None)?;
329333
info!("Posted base comment to github, no reviewers listed yet");
@@ -352,10 +356,11 @@ impl<'a> RfcBotCommand<'a> {
352356

353357
let review_requests = issue_subteam_members.iter()
354358
.map(|member| {
359+
// let's assume the initiator has reviewed it
355360
NewFcpReviewRequest {
356361
fk_proposal: proposal.id,
357362
fk_reviewer: member.id,
358-
reviewed: false,
363+
reviewed: if member.id == author.id { true } else { false },
359364
}
360365
})
361366
.collect::<Vec<_>>();
@@ -373,7 +378,10 @@ impl<'a> RfcBotCommand<'a> {
373378

374379
let new_gh_comment =
375380
RfcBotComment::new(issue,
376-
CommentType::FcpProposed(disp, &review_requests, &[]));
381+
CommentType::FcpProposed(author,
382+
disp,
383+
&review_requests,
384+
&[]));
377385

378386
new_gh_comment.post(Some(gh_comment.id))?;
379387

@@ -525,7 +533,7 @@ impl<'a> RfcBotCommand<'a> {
525533
let invocation = tokens.next().ok_or(DashError::Misc)?;
526534

527535
match invocation {
528-
"fcp" => {
536+
"fcp" | "pr" => {
529537
let subcommand = tokens.next().ok_or(DashError::Misc)?;
530538

531539
debug!("Parsed command as new FCP proposal");
@@ -581,7 +589,8 @@ struct RfcBotComment<'a> {
581589
}
582590

583591
enum CommentType<'a> {
584-
FcpProposed(FcpDisposition,
592+
FcpProposed(&'a GitHubUser,
593+
FcpDisposition,
585594
&'a [(GitHubUser, FcpReviewRequest)],
586595
&'a [(GitHubUser, FcpConcern)]),
587596
FcpProposalCancelled(&'a GitHubUser),
@@ -602,10 +611,13 @@ impl<'a> RfcBotComment<'a> {
602611
fn format(&self) -> DashResult<String> {
603612

604613
match self.comment_type {
605-
CommentType::FcpProposed(disposition, reviewers, concerns) => {
606-
let mut msg = String::from("FCP proposed with disposition to ");
614+
CommentType::FcpProposed(initiator, disposition, reviewers, concerns) => {
615+
let mut msg = String::from("Team member ");
616+
msg.push_str(&initiator.login);
617+
msg.push_str(" has proposed to ");
607618
msg.push_str(disposition.repr());
608-
msg.push_str(". Review requested from:\n\n");
619+
msg.push_str(" this. The next step is review by the rest of the tagged ");
620+
msg.push_str("teams:\n\n");
609621

610622
for &(ref member, ref review_request) in reviewers {
611623

@@ -643,19 +655,24 @@ impl<'a> RfcBotComment<'a> {
643655
}
644656
}
645657

658+
msg.push_str("\nOnce these reviewers reach consensus, this will enter its final ");
659+
msg.push_str("comment period. If you spot a major issue that hasn't been raised ");
660+
msg.push_str("at any point in this process, please speak up!\n");
661+
646662
msg.push_str("\nSee [this document](");
647663
msg.push_str("https://github.com/dikaiosune/rust-dashboard/blob/master/RFCBOT.md");
648664
msg.push_str(") for info about what commands tagged team members can give me.");
649665

650666
Ok(msg)
651667
}
652668
CommentType::FcpProposalCancelled(initiator) => {
653-
Ok(format!("@{} FCP proposal cancelled.", initiator.login))
669+
Ok(format!("@{} proposal cancelled.", initiator.login))
654670
}
655671
CommentType::FcpAllReviewedNoConcerns => {
656672
Ok("All relevant subteam members have reviewed. No concerns remain.".to_string())
657673
}
658674
CommentType::FcpWeekPassed => {
675+
// TODO add ping to original proposal author
659676
Ok("It has been one week since all blocks to the FCP were resolved.".to_string())
660677
}
661678
}

0 commit comments

Comments
 (0)