manager: Remove Stale
label if present
The stale label provides an easy way to force CI runs for issues after changing dependencies.
This commit is contained in:
parent
e274f6206c
commit
f04beb5dea
1
techtree-manager/Cargo.lock
generated
1
techtree-manager/Cargo.lock
generated
|
@ -1349,6 +1349,7 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sha256",
|
"sha256",
|
||||||
|
"time",
|
||||||
"tokio",
|
"tokio",
|
||||||
"url",
|
"url",
|
||||||
]
|
]
|
||||||
|
|
|
@ -14,5 +14,6 @@ petgraph = "0.8.1"
|
||||||
serde = { version = "1.0.219", features = ["derive"] }
|
serde = { version = "1.0.219", features = ["derive"] }
|
||||||
serde_json = "1.0.140"
|
serde_json = "1.0.140"
|
||||||
sha256 = "1.6.0"
|
sha256 = "1.6.0"
|
||||||
|
time = "0.3.41"
|
||||||
tokio = { version = "1.45.0", features = ["full"] }
|
tokio = { version = "1.45.0", features = ["full"] }
|
||||||
url = "2.5.4"
|
url = "2.5.4"
|
||||||
|
|
|
@ -78,5 +78,42 @@ pub async fn update_bot_comment(
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.context("Failed to update comment body")?;
|
.context("Failed to update comment body")?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn remove_stale_label(
|
||||||
|
forgejo: &forgejo_api::Forgejo,
|
||||||
|
meta: &crate::event_meta::RepoMeta,
|
||||||
|
issue_number: u64,
|
||||||
|
) -> anyhow::Result<()> {
|
||||||
|
let labels = forgejo
|
||||||
|
.issue_get_labels(&meta.owner, &meta.name, issue_number)
|
||||||
|
.await
|
||||||
|
.context("Failed fetching issue labels")?;
|
||||||
|
|
||||||
|
let stale_label_id = labels
|
||||||
|
.iter()
|
||||||
|
.filter(|l| l.name.as_deref() == Some("Stale"))
|
||||||
|
.next()
|
||||||
|
.map(|l| l.id.unwrap());
|
||||||
|
|
||||||
|
if let Some(stale_label_id) = stale_label_id {
|
||||||
|
log::info!("Removing `Stale` label from issue #{issue_number}...");
|
||||||
|
|
||||||
|
forgejo
|
||||||
|
.issue_remove_label(
|
||||||
|
&meta.owner,
|
||||||
|
&meta.name,
|
||||||
|
issue_number,
|
||||||
|
stale_label_id,
|
||||||
|
forgejo_api::structs::DeleteLabelsOption {
|
||||||
|
updated_at: Some(time::OffsetDateTime::now_utc()),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.context("Failed to remove the `Stale` label")?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,6 +99,12 @@ async fn run() -> anyhow::Result<()> {
|
||||||
if let Some(bot_comment) = bot_comment {
|
if let Some(bot_comment) = bot_comment {
|
||||||
if bot_comment.body.contains(&hash) {
|
if bot_comment.body.contains(&hash) {
|
||||||
log::info!("Issue #{issue} is up-to-date, not editing comment.");
|
log::info!("Issue #{issue} is up-to-date, not editing comment.");
|
||||||
|
issue::remove_stale_label(&forgejo, &meta.issue.repository, issue)
|
||||||
|
.await
|
||||||
|
.with_context(|| {
|
||||||
|
format!("Failed to remove `Stale` label from issue #{issue}")
|
||||||
|
})?;
|
||||||
|
|
||||||
continue 'issues;
|
continue 'issues;
|
||||||
}
|
}
|
||||||
bot_comment.id
|
bot_comment.id
|
||||||
|
@ -128,6 +134,10 @@ async fn run() -> anyhow::Result<()> {
|
||||||
issue::update_bot_comment(&forgejo, &meta.issue.repository, comment_id, full_text)
|
issue::update_bot_comment(&forgejo, &meta.issue.repository, comment_id, full_text)
|
||||||
.await
|
.await
|
||||||
.with_context(|| format!("Failed to update the bot comment in issue #{issue}"))?;
|
.with_context(|| format!("Failed to update the bot comment in issue #{issue}"))?;
|
||||||
|
|
||||||
|
issue::remove_stale_label(&forgejo, &meta.issue.repository, issue)
|
||||||
|
.await
|
||||||
|
.with_context(|| format!("Failed to remove `Stale` label from issue #{issue}"))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue