Skip to content

Commit

Permalink
FCP + concern => PFCP per aturon's request; also refactor into execut…
Browse files Browse the repository at this point in the history
…e_ffcp_actions.
  • Loading branch information
Centril committed Apr 21, 2018
1 parent dac6c55 commit 13c38fd
Showing 1 changed file with 43 additions and 21 deletions.
64 changes: 43 additions & 21 deletions src/github/nag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,30 +458,33 @@ fn evaluate_nags() -> DashResult<()> {
}
};

// Execute FFCP actions:
if is_rfc_repo(&issue) {
match disp {
FcpDisposition::Merge => {
// TODO: This one will require a lot of work to
// auto-merge RFCs and create the tracking issue.
},
FcpDisposition::Close => {
let _ = issue.add_label(Label::Closed);
issue.remove_label(Label::DispositionClose);
issue.close();
},
FcpDisposition::Postpone => {
let _ = issue.add_label(Label::Postponed);
issue.remove_label(Label::DispositionPostpone);
issue.close();
},
}
}
execute_ffcp_actions(&issue, disp);
}

Ok(())
}

fn execute_ffcp_actions(issue: &Issue, disposition: FcpDisposition) {
if !is_rfc_repo(&issue) { return; }

match disposition {
FcpDisposition::Merge => {
// TODO: This one will require a lot of work to
// auto-merge RFCs and create the tracking issue.
},
FcpDisposition::Close => {
let _ = issue.add_label(Label::Closed);
issue.remove_label(Label::DispositionClose);
issue.close();
},
FcpDisposition::Postpone => {
let _ = issue.add_label(Label::Postponed);
issue.remove_label(Label::DispositionPostpone);
issue.close();
},
}
}

fn list_review_requests(proposal_id: i32) -> DashResult<Vec<(GitHubUser, FcpReviewRequest)>> {
use domain::schema::{fcp_review_request, githubuser};

Expand Down Expand Up @@ -846,9 +849,10 @@ impl<'a> RfcBotCommand<'a> {
}
RfcBotCommand::NewConcern(concern_name) => {

if let Some(proposal) = existing_proposal {
if let Some(mut proposal) = existing_proposal {
// check for existing concern
use domain::schema::fcp_concern::dsl::*;
use domain::schema::fcp_proposal::dsl::*;

let existing_concern = fcp_concern
.filter(fk_proposal.eq(proposal.id))
Expand All @@ -870,8 +874,26 @@ impl<'a> RfcBotCommand<'a> {
diesel::insert(&new_concern)
.into(fcp_concern)
.execute(conn)?;

// Take us out of FCP and back into PFCP if need be:
if proposal.fcp_start.is_some() {
// Update DB: FCP is not started anymore.
proposal.fcp_start = None;
match diesel::update(fcp_proposal.find(proposal.id))
.set(&proposal)
.execute(conn) {
Ok(_) => (),
Err(why) => {
error!("Unable to mark FCP {} as unstarted: {:?}", proposal.id, why);
return Ok(());
}
}

// Update labels:
let _ = issue.add_label(Label::PFCP);
issue.remove_label(Label::FCP);
}
}

}
}
RfcBotCommand::ResolveConcern(concern_name) => {
Expand Down

0 comments on commit 13c38fd

Please sign in to comment.