Skip to content

Fix commands in pull request comments #1652

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,10 @@ pub struct Issue {
pub assignees: Vec<User>,
/// This is true if this is a pull request.
///
/// Note that this field does not come from GitHub. This is manually added
/// when the webhook arrives to help differentiate between an event
/// related to an issue versus a pull request.
///
/// GitHub *does* actually populate this field on some events, but triagebot ignores that data
/// and just stores a bool here when appropriate.
#[serde(skip)]
/// On some events, such as pull request comments, GitHub passes an empty map type
/// in this field, but most of the time this is only set by triagebot where
/// appropriate.
#[serde(default, deserialize_with = "is_pull_request")]
pub pull_request: bool,
/// Whether or not the pull request was merged.
#[serde(default)]
Expand All @@ -293,6 +290,22 @@ pub struct Issue {
pub head: Option<CommitBase>,
}

fn is_pull_request<'de, D>(deserializer: D) -> Result<bool, D::Error>
where
D: serde::de::Deserializer<'de>,
{
#[derive(serde::Deserialize)]
struct PullRequestDetails {
// none for now
}

use serde::de::Deserialize;
match PullRequestDetails::deserialize(deserializer) {
Ok(_) => Ok(true),
Err(e) => Err(e),
}
}

/// Contains only the parts of `Issue` that are needed for turning the issue title into a Zulip
/// topic.
#[derive(Clone, Debug, PartialEq, Eq)]
Expand Down