Skip to content

Commit

Permalink
Use Zulip IDs instead of GitHub login in rfcbot issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Urgau committed Mar 24, 2024
1 parent a6afc94 commit 5883496
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use tera::{Context, Tera};
use crate::{
github::{self, GithubClient, Repository},
http_client::{CompilerMeeting, HttpClient},
rfcbot,
};

#[async_trait]
Expand Down Expand Up @@ -62,14 +61,20 @@ pub struct FCPConcernDetails {
pub concern_url: String,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct FCPReviewerDetails {
pub github_login: String,
pub zulip_id: Option<u64>,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct FCPDetails {
pub bot_tracking_comment_html_url: String,
pub bot_tracking_comment_content: String,
pub initiating_comment_html_url: String,
pub initiating_comment_content: String,
pub disposition: String,
pub pending_reviewers: Vec<rfcbot::Reviewer>,
pub pending_reviewers: Vec<FCPReviewerDetails>,
pub concerns: Vec<FCPConcernDetails>,
}

Expand Down
21 changes: 20 additions & 1 deletion src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1719,6 +1719,12 @@ impl<'q> IssuesQuery for Query<'q> {
HashMap::new()
};

let zulip_map = if include_fcp_details {
Some(crate::team_data::zulip_map(client).await?)
} else {
None
};

let mut issues_decorator = Vec::new();
let re = regex::Regex::new("https://github.com/rust-lang/|/").unwrap();
let re_zulip_link = regex::Regex::new(r"\[stream\]:\s").unwrap();
Expand Down Expand Up @@ -1761,7 +1767,20 @@ impl<'q> IssuesQuery for Query<'q> {
pending_reviewers: fcp
.reviews
.iter()
.filter_map(|r| (!r.approved).then(|| r.reviewer.clone()))
.filter_map(|r| {
(!r.approved).then(|| crate::actions::FCPReviewerDetails {
github_login: r.reviewer.login.clone(),
zulip_id: zulip_map
.as_ref()
.map(|map| {
map.users
.iter()
.find(|&(_, &github)| github == r.reviewer.id)
.map(|v| *v.0)
})
.flatten(),
})
})
.collect(),
concerns: fcp
.concerns
Expand Down
2 changes: 1 addition & 1 deletion src/rfcbot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct FCP {
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Reviewer {
pub id: u32,
pub id: u64,
pub login: String,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion templates/_issues_rfcbot.tt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{%- for issue in issues %}
{%- if issue.fcp_details is object %}
- {{issue.fcp_details.disposition}}: [{{issue.title}} ({{issue.repo_name}}#{{issue.number}})]({{issue.fcp_details.bot_tracking_comment_html_url}})
*{% for reviewer in issue.fcp_details.pending_reviewers %} @**{{reviewer.login}}**{%else%} no pending checkboxs{% endfor %}
*{% for reviewer in issue.fcp_details.pending_reviewers %} @**|{{reviewer.zulip_id}}**{%else%} no pending checkboxs{% endfor %}
*{% for concern in issue.fcp_details.concerns %} [{{concern.name}} (by {{concern.reviewer_login}})]({{concern.concern_url}}){%else%} no pending concerns{% endfor -%}
{% else %}
- "{{issue.title}}" {{issue.repo_name}}#{{issue.number}}
Expand Down

0 comments on commit 5883496

Please sign in to comment.