Skip to content

Human friendly incantations + Auto Closing/Postponing RFCs + More labels #197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 30, 2018
19 changes: 19 additions & 0 deletions src/github/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,25 @@ impl Client {
None
}

pub fn close_pr(&self, repo: &str, issue_num: i32) -> DashResult<()> {
let url = format!("{}/repos/{}/pulls/{}", BASE_URL, repo, issue_num);

let mut obj = BTreeMap::new();
obj.insert("status", "closed");
let payload = serde_json::to_string(&obj)?;

let mut res = self.patch(&url, &payload)?;

match res.status {
StatusCode::Ok => Ok(()),
_ => {
let mut body = String::new();
res.read_to_string(&mut body)?;
Err(DashError::Misc(Some(body)))
}
}
}

pub fn add_label(&self, repo: &str, issue_num: i32, label: &str) -> DashResult<()> {
let url = format!("{}/repos/{}/issues/{}/labels", BASE_URL, repo, issue_num);
let payload = serde_json::to_string(&[label])?;
Expand Down
Loading