|
| 1 | +use crate::bors::Comment; |
| 2 | +use crate::bors::RepositoryState; |
| 3 | +use crate::database::PgDbClient; |
| 4 | +use crate::github::PullRequest; |
| 5 | +use std::sync::Arc; |
| 6 | + |
| 7 | +pub(super) async fn command_info( |
| 8 | + repo: Arc<RepositoryState>, |
| 9 | + pr: &PullRequest, |
| 10 | + db: Arc<PgDbClient>, |
| 11 | +) -> anyhow::Result<()> { |
| 12 | + // Geting PR info from database |
| 13 | + let pr_model = db.get_pull_request(repo.repository(), pr.number).await?; |
| 14 | + |
| 15 | + // Building the info message |
| 16 | + let mut info_lines = Vec::new(); |
| 17 | + |
| 18 | + // Approval info |
| 19 | + if let Some(pr) = pr_model { |
| 20 | + if let Some(approved_by) = pr.approved_by { |
| 21 | + info_lines.push(format!("- **Approved by:** @{}", approved_by)); |
| 22 | + } else { |
| 23 | + info_lines.push("- **Approved by:** No one".to_string()); |
| 24 | + } |
| 25 | + |
| 26 | + // Priority info |
| 27 | + if let Some(priority) = pr.priority { |
| 28 | + info_lines.push(format!("- **Priority:** {}", priority)); |
| 29 | + } else { |
| 30 | + info_lines.push("- **Priority:** None".to_string()); |
| 31 | + } |
| 32 | + |
| 33 | + // Build status |
| 34 | + if let Some(try_build) = pr.try_build { |
| 35 | + info_lines.push(format!("- **Try build branch:** {}", try_build.branch)); |
| 36 | + } else { |
| 37 | + info_lines.push("- **Try build:** None".to_string()); |
| 38 | + } |
| 39 | + } else { |
| 40 | + info_lines.push("- **PR not found in database**".to_string()); |
| 41 | + } |
| 42 | + |
| 43 | + // Merge status (placeholder for future) |
| 44 | + info_lines.push("- **Merge status:** Not implemented yet".to_string()); |
| 45 | + |
| 46 | + // Queue link (placeholder for future) |
| 47 | + info_lines.push("- **Queue link:** Not implemented yet".to_string()); |
| 48 | + |
| 49 | + // Joining all lines |
| 50 | + let info = info_lines.join("\n"); |
| 51 | + |
| 52 | + // Post the comment |
| 53 | + repo.client |
| 54 | + .post_comment(pr.number, Comment::new(info)) |
| 55 | + .await?; |
| 56 | + |
| 57 | + Ok(()) |
| 58 | +} |
0 commit comments