Skip to content

Commit

Permalink
fix(ghcup): sig
Browse files Browse the repository at this point in the history
  • Loading branch information
PhotonQuantum committed Jul 9, 2024
1 parent 0c7437a commit 47270ef
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/ghcup/packages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ impl SnapshotStorage<SnapshotMeta> for GhcupPackages {
let latest_yaml_obj = filter_map_file_objs(
list_files(&client, repo_config, &self.ghcup_repo_config.branch).await?,
)
.filter(|obj| !obj.is_sig)
.max_by(|x, y| x.version.cmp(&y.version))
.ok_or_else(|| Error::ProcessError(String::from("no config file found")))?;

Expand Down
2 changes: 1 addition & 1 deletion src/ghcup/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use serde::Deserialize;

use super::utils::Version;

pub const EXPECTED_CONFIG_VERSION: Version = Version::new(0, 0, 7);
pub const EXPECTED_CONFIG_VERSION: Version = Version::new(0, 0, 8);

#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
Expand Down
7 changes: 6 additions & 1 deletion src/ghcup/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use super::GhcupRepoConfig;

lazy_static! {
static ref YAML_CONFIG_PATTERN: regex::Regex =
regex::Regex::new(r"ghcup-(?P<ver>\d.\d.\d).yaml$").unwrap();
regex::Regex::new(r"ghcup-(?P<ver>\d.\d.\d).yaml(?P<sig>.sig)?$").unwrap();
}

// order is reverted to derive Ord ;)
Expand Down Expand Up @@ -81,13 +81,15 @@ enum NodeType {
pub struct ObjectInfo {
pub name: String,
pub path: String,
pub is_sig: bool,
pub version: Version,
}

#[derive(Debug, Clone)]
pub struct ObjectInfoWithUrl {
pub name: String,
pub path: String,
pub is_sig: bool,
pub version: Version,
pub url: String,
}
Expand Down Expand Up @@ -124,6 +126,7 @@ pub fn filter_map_file_objs(
let name = f.path.split('/').last().unwrap().to_string();
Some(ObjectInfo {
name,
is_sig: c.name("sig").is_some(),
path: f.path.clone(),
version: Version::from_str(m.as_str()).ok()?,
})
Expand All @@ -137,6 +140,7 @@ pub async fn get_raw_blob_url(
config: &GhcupRepoConfig,
object: ObjectInfo,
) -> Result<ObjectInfoWithUrl> {
println!("decoding https://api.github.com/repos/{}/contents/{}", config.repo, object.path);
let content: ContentMeta = client
.get(format!(
"https://api.github.com/repos/{}/contents/{}",
Expand All @@ -150,6 +154,7 @@ pub async fn get_raw_blob_url(
name: object.name,
path: object.path,
version: object.version,
is_sig: object.is_sig,
url: content.download_url,
})
}

0 comments on commit 47270ef

Please sign in to comment.