Permalink
Checking mergeability…
Don’t worry, you can still create the pull request.
Comparing changes
Open a pull request
- 1 commit
- 3 files changed
- 0 commit comments
- 1 contributor
Unified
Split
Showing
with
36 additions
and 0 deletions.
- +18 −0 src/github/client.rs
- +4 −0 src/github/command.rs
- +14 −0 src/github/nag.rs
| @@ -221,6 +221,24 @@ impl Client { | |||
| self.deserialize(&mut self.patch(&url, &payload)?) | |||
| } | |||
|
|
|||
| pub fn append_to_op(&self, repo: &str, issue_num: i32, current_body: &str, text_to_append: &str) | |||
| -> DashResult<()> | |||
| { | |||
| let url = format!("{}/repos/{}/issues/{}", | |||
| BASE_URL, | |||
| repo, | |||
| issue_num); | |||
|
|
|||
| let new_body = format!("{}\n----\n## {}\n{}", | |||
| current_body, | |||
| Utc::now().format("%B %d %Y"), | |||
| text_to_append); | |||
|
|
|||
| let payload = serde_json::to_string(&btreemap!("body" => new_body))?; | |||
|
|
|||
| self.deserialize(&mut self.patch(&url, &payload)?) | |||
| } | |||
|
|
|||
| fn patch(&self, url: &str, payload: &str) -> Result<Response, hyper::error::Error> { | |||
| self.set_headers(self.client.patch(url).body(payload)) | |||
| .send() | |||
| @@ -240,6 +240,9 @@ fn from_invocation_line<'a> | |||
|
|
|||
| Ok(RfcBotCommand::FeedbackRequest(&user[1..])) | |||
| } | |||
| "summarize" | "summary" => { | |||
| Ok(RfcBotCommand::Summary) | |||
| } | |||
| _ => parse_fcp_subcommand(setup, command, invocation, false), | |||
| } | |||
| } | |||
| @@ -256,6 +259,7 @@ pub enum RfcBotCommand<'a> { | |||
| teams: BTreeSet<&'a str>, | |||
| question: &'a str, | |||
| }, | |||
| Summary, | |||
| } | |||
|
|
|||
| impl<'a> RfcBotCommand<'a> { | |||
| @@ -33,6 +33,11 @@ impl Issue { | |||
| ok_or!(GH.close_issue(&self.repository, self.number), why => | |||
| error!("Unable to close issue {:?}: {:?}", self, why)); | |||
| } | |||
|
|
|||
| fn append_to_op(&self, text_to_append: &str) { | |||
| ok_or!(GH.append_to_op(&self.repository, self.number, &self.body, text_to_append), | |||
| why => error!("Unable to append to issue OP {:?}: {:?}", self, why)) | |||
| } | |||
| } | |||
|
|
|||
| lazy_static! { | |||
| @@ -731,6 +736,8 @@ impl<'a> RfcBotCommand<'a> { | |||
| process_resolve_concern(author, issue, comment, concern_name), | |||
| FeedbackRequest(username) => | |||
| process_feedback_request(author, issue, username), | |||
| Summary => | |||
| process_summary_request(author, issue, comment), | |||
| } | |||
| } | |||
| } | |||
| @@ -1037,6 +1044,13 @@ fn process_feedback_request(author: &GitHubUser, issue: &Issue, username: &str) | |||
| Ok(()) | |||
| } | |||
|
|
|||
| fn process_summary_request(author: &GitHubUser, issue: &Issue, comment: &IssueComment) | |||
| -> DashResult<()> | |||
| { | |||
| issue.append_to_op(&comment.body); | |||
| Ok(()) | |||
| } | |||
|
|
|||
| struct RfcBotComment<'a> { | |||
| issue: &'a Issue, | |||
| body: String, | |||