|
@@ -297,6 +297,15 @@ pub struct Issue {
|
|
|
/// The head commit for a PR (the branch from the source repo).
|
|
|
#[serde(default)]
|
|
|
pub head: Option<CommitBase>,
|
|
|
+ /// Whether it is open or closed.
|
|
|
+ pub state: IssueState,
|
|
|
+}
|
|
|
+
|
|
|
+#[derive(Debug, serde::Deserialize, Eq, PartialEq)]
|
|
|
+#[serde(rename_all = "snake_case")]
|
|
|
+pub enum IssueState {
|
|
|
+ Open,
|
|
|
+ Closed,
|
|
|
}
|
|
|
|
|
|
/// Contains only the parts of `Issue` that are needed for turning the issue title into a Zulip
|
|
@@ -467,6 +476,10 @@ impl Issue {
|
|
|
self.pull_request.is_some()
|
|
|
}
|
|
|
|
|
|
+ pub fn is_open(&self) -> bool {
|
|
|
+ self.state == IssueState::Open
|
|
|
+ }
|
|
|
+
|
|
|
pub async fn get_comment(&self, client: &GithubClient, id: usize) -> anyhow::Result<Comment> {
|
|
|
let comment_url = format!("{}/issues/comments/{}", self.repository().url(), id);
|
|
|
let comment = client.json(client.get(&comment_url)).await?;
|