silly goober bot

refactor: update for new vers

+21 -20
+21 -20
src/commands/misc/nixpkgs.rs
··· 1 1 use color_eyre::eyre::Result; 2 - use git_tracker::Tracker; 2 + use git_tracker::TrackedRepository; 3 3 use poise::{serenity_prelude::CreateEmbed, CreateReply}; 4 4 use serde::Deserialize; 5 5 use std::env; ··· 20 20 21 21 let nixpkgs_path = env::var("NIXPKGS").expect("NIXPKGS not set"); 22 22 let github_token = env::var("GITHUB_TOKEN").expect("GITHUB_TOKEN not set"); 23 - let tracker = Tracker::from_path(&nixpkgs_path)?; 23 + let tracker = TrackedRepository::new( 24 + nixpkgs_path.into(), 25 + NIXPKGS_URL.to_string(), 26 + "origin".to_string(), 27 + ); 24 28 25 29 let client = &ctx.data().client; 26 30 ··· 44 48 return Ok(()); 45 49 }; 46 50 47 - let mut status_results = vec![]; 48 - for branch_name in &[ 49 - "master", 50 - "staging", 51 - "nixpkgs-unstable", 52 - "nixos-unstable-small", 53 - "nixos-unstable", 54 - ] { 55 - let full_branch_name = format!("origin/{branch_name}"); 56 - let has_pr = tracker.branch_contains_sha(&full_branch_name, &commit_sha)?; 51 + let branchs = vec![ 52 + "master".to_string(), 53 + "staging".to_string(), 54 + "nixpkgs-unstable".to_string(), 55 + "nixos-unstable-small".to_string(), 56 + "nixos-unstable".to_string(), 57 + ]; 57 58 58 - if has_pr { 59 - status_results.push(format!("`{branch_name}` ✅")); 60 - } else { 61 - status_results.push(format!("`{branch_name}` ❌")); 62 - } 63 - } 59 + let prd_branches = tracker.branches_contain_sha(&branchs, &commit_sha)?; 64 60 65 61 // if we don't find the commit in any branches from above, we can pretty safely assume 66 62 // it's an unmerged PR 67 - let embed_description: String = if status_results.is_empty() { 63 + let embed_description: String = if prd_branches.is_empty() { 68 64 "It doesn't look like this PR has been merged yet! (or maybe I just haven't updated)" 69 65 .to_string() 70 66 } else { 71 - status_results.join("\n") 67 + prd_branches 68 + .iter() 69 + .fold(String::new(), |acc, (name, has_commit)| { 70 + let emoji = if *has_commit { "✅" } else { "❌" }; 71 + format!("{acc}\n{name} {emoji}") 72 + }) 72 73 }; 73 74 74 75 let embed = CreateReply::default().embed(