Skip to content

Commit 9f52efd

Browse files
Centrilanp
authored andcommitted
FCP + concern => PFCP per aturon's request; also refactor into execute_ffcp_actions.
1 parent 30fbfe1 commit 9f52efd

File tree

1 file changed

+43
-21
lines changed

1 file changed

+43
-21
lines changed

src/github/nag.rs

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -458,30 +458,33 @@ fn evaluate_nags() -> DashResult<()> {
458458
}
459459
};
460460

461-
// Execute FFCP actions:
462-
if is_rfc_repo(&issue) {
463-
match disp {
464-
FcpDisposition::Merge => {
465-
// TODO: This one will require a lot of work to
466-
// auto-merge RFCs and create the tracking issue.
467-
},
468-
FcpDisposition::Close => {
469-
let _ = issue.add_label(Label::Closed);
470-
issue.remove_label(Label::DispositionClose);
471-
issue.close();
472-
},
473-
FcpDisposition::Postpone => {
474-
let _ = issue.add_label(Label::Postponed);
475-
issue.remove_label(Label::DispositionPostpone);
476-
issue.close();
477-
},
478-
}
479-
}
461+
execute_ffcp_actions(&issue, disp);
480462
}
481463

482464
Ok(())
483465
}
484466

467+
fn execute_ffcp_actions(issue: &Issue, disposition: FcpDisposition) {
468+
if !is_rfc_repo(&issue) { return; }
469+
470+
match disposition {
471+
FcpDisposition::Merge => {
472+
// TODO: This one will require a lot of work to
473+
// auto-merge RFCs and create the tracking issue.
474+
},
475+
FcpDisposition::Close => {
476+
let _ = issue.add_label(Label::Closed);
477+
issue.remove_label(Label::DispositionClose);
478+
issue.close();
479+
},
480+
FcpDisposition::Postpone => {
481+
let _ = issue.add_label(Label::Postponed);
482+
issue.remove_label(Label::DispositionPostpone);
483+
issue.close();
484+
},
485+
}
486+
}
487+
485488
fn list_review_requests(proposal_id: i32) -> DashResult<Vec<(GitHubUser, FcpReviewRequest)>> {
486489
use domain::schema::{fcp_review_request, githubuser};
487490

@@ -846,9 +849,10 @@ impl<'a> RfcBotCommand<'a> {
846849
}
847850
RfcBotCommand::NewConcern(concern_name) => {
848851

849-
if let Some(proposal) = existing_proposal {
852+
if let Some(mut proposal) = existing_proposal {
850853
// check for existing concern
851854
use domain::schema::fcp_concern::dsl::*;
855+
use domain::schema::fcp_proposal::dsl::*;
852856

853857
let existing_concern = fcp_concern
854858
.filter(fk_proposal.eq(proposal.id))
@@ -870,8 +874,26 @@ impl<'a> RfcBotCommand<'a> {
870874
diesel::insert(&new_concern)
871875
.into(fcp_concern)
872876
.execute(conn)?;
877+
878+
// Take us out of FCP and back into PFCP if need be:
879+
if proposal.fcp_start.is_some() {
880+
// Update DB: FCP is not started anymore.
881+
proposal.fcp_start = None;
882+
match diesel::update(fcp_proposal.find(proposal.id))
883+
.set(&proposal)
884+
.execute(conn) {
885+
Ok(_) => (),
886+
Err(why) => {
887+
error!("Unable to mark FCP {} as unstarted: {:?}", proposal.id, why);
888+
return Ok(());
889+
}
890+
}
891+
892+
// Update labels:
893+
let _ = issue.add_label(Label::PFCP);
894+
issue.remove_label(Label::FCP);
895+
}
873896
}
874-
875897
}
876898
}
877899
RfcBotCommand::ResolveConcern(concern_name) => {

0 commit comments

Comments
 (0)