tangled
alpha
login
or
join now
isabelroses.com
/
blahaj
1
fork
atom
silly goober bot
1
fork
atom
overview
issues
pulls
pipelines
refactor: update for new vers
isabelroses.com
1 year ago
4c6b2265
4cc339f4
+21
-20
1 changed file
expand all
collapse all
unified
split
src
commands
misc
nixpkgs.rs
+21
-20
src/commands/misc/nixpkgs.rs
···
1
1
use color_eyre::eyre::Result;
2
2
-
use git_tracker::Tracker;
2
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
23
-
let tracker = Tracker::from_path(&nixpkgs_path)?;
23
23
+
let tracker = TrackedRepository::new(
24
24
+
nixpkgs_path.into(),
25
25
+
NIXPKGS_URL.to_string(),
26
26
+
"origin".to_string(),
27
27
+
);
24
28
25
29
let client = &ctx.data().client;
26
30
···
44
48
return Ok(());
45
49
};
46
50
47
47
-
let mut status_results = vec![];
48
48
-
for branch_name in &[
49
49
-
"master",
50
50
-
"staging",
51
51
-
"nixpkgs-unstable",
52
52
-
"nixos-unstable-small",
53
53
-
"nixos-unstable",
54
54
-
] {
55
55
-
let full_branch_name = format!("origin/{branch_name}");
56
56
-
let has_pr = tracker.branch_contains_sha(&full_branch_name, &commit_sha)?;
51
51
+
let branchs = vec![
52
52
+
"master".to_string(),
53
53
+
"staging".to_string(),
54
54
+
"nixpkgs-unstable".to_string(),
55
55
+
"nixos-unstable-small".to_string(),
56
56
+
"nixos-unstable".to_string(),
57
57
+
];
57
58
58
58
-
if has_pr {
59
59
-
status_results.push(format!("`{branch_name}` ✅"));
60
60
-
} else {
61
61
-
status_results.push(format!("`{branch_name}` ❌"));
62
62
-
}
63
63
-
}
59
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
67
-
let embed_description: String = if status_results.is_empty() {
63
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
71
-
status_results.join("\n")
67
67
+
prd_branches
68
68
+
.iter()
69
69
+
.fold(String::new(), |acc, (name, has_commit)| {
70
70
+
let emoji = if *has_commit { "✅" } else { "❌" };
71
71
+
format!("{acc}\n{name} {emoji}")
72
72
+
})
72
73
};
73
74
74
75
let embed = CreateReply::default().embed(