m/cup
1
0
mirror of https://github.com/sergi0g/cup.git synced 2025-11-19 02:13:41 -05:00

feat: add ability to ignore certain update types (#91)

This commit is contained in:
Seow Alex
2025-04-12 14:37:28 +08:00
committed by GitHub
parent efea81ef39
commit 80a295680d
4 changed files with 68 additions and 5 deletions

View File

@@ -3,6 +3,7 @@ use std::time::SystemTime;
use itertools::Itertools;
use crate::{
config::UpdateType,
error,
http::Client,
structs::{
@@ -150,6 +151,7 @@ pub async fn get_latest_tag(
&headers,
base,
&image.version_info.as_ref().unwrap().format_str,
ctx,
client,
)
.await
@@ -214,6 +216,7 @@ pub async fn get_extra_tags(
headers: &[(&str, Option<&str>)],
base: &Version,
format_str: &str,
ctx: &Context,
client: &Client,
) -> Result<(Vec<Version>, Option<String>), String> {
let response = client.get(url, &headers, false).await;
@@ -237,7 +240,18 @@ pub async fn get_extra_tags(
}
_ => false,
})
.map(|(tag, _)| tag)
.filter_map(|(tag, _)| match ctx.config.ignore_update_type {
UpdateType::None => Some(tag),
UpdateType::Major => Some(tag).filter(|tag| base.major == tag.major),
UpdateType::Minor => {
Some(tag).filter(|tag| base.major == tag.major && base.minor == tag.minor)
}
UpdateType::Patch => Some(tag).filter(|tag| {
base.major == tag.major
&& base.minor == tag.minor
&& base.patch == tag.patch
}),
})
.dedup()
.collect();
Ok((result, next_url))