Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion registry/d2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version_order = "semver"

bins = ["d2"]
[[backends]]
full = "aqua:terrastruct/d2"
full = "aqua:d2lang/d2"

[[backends]]
full = "github:terrastruct/d2"
Expand Down
2 changes: 1 addition & 1 deletion registry/dagu.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
backends = ["aqua:dagu-org/dagu"]
backends = ["aqua:dagucloud/dagu"]
bins = ["dagu"]
description = "Yet another cron alternative with a Web UI, but with much more capabilities. It aims to solve greater problems"
test = { cmd = "dagu version", expected = "{{version}}" }
Expand Down
2 changes: 1 addition & 1 deletion registry/gitui.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
backends = ["aqua:extrawurst/gitui", "asdf:looztra/asdf-gitui", "cargo:gitui"]
backends = ["aqua:gitui-org/gitui", "asdf:looztra/asdf-gitui", "cargo:gitui"]
bins = ["gitui"]
description = "Blazing 💥 fast terminal-ui for git written in rust"
version_order = "semver"
2 changes: 1 addition & 1 deletion registry/gradle.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
backends = ["aqua:gradle/gradle", "vfox:mise-plugins/vfox-gradle"]
backends = ["aqua:gradle/gradle-distributions", "vfox:mise-plugins/vfox-gradle"]
bins = ["gradle"]
description = "Gradle is the open source build system of choice for Java, Android, and Kotlin developers"
test = { cmd = "gradle -V", expected = "Gradle", tools = ["java"] }
Expand Down
2 changes: 1 addition & 1 deletion registry/ktlint.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
backends = ["aqua:pinterest/ktlint", "asdf:mise-plugins/mise-ktlint"]
backends = ["aqua:ktlint/ktlint", "asdf:mise-plugins/mise-ktlint"]
bins = ["ktlint"]
description = "An anti-bikeshedding Kotlin linter with built-in formatter"
version_order = "semver"
Expand Down
2 changes: 1 addition & 1 deletion registry/kubeseal.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
backends = [
"aqua:bitnami-labs/sealed-secrets",
"aqua:bitnami/sealed-secrets",
"asdf:stefansedich/asdf-kubeseal",
]
bins = ["kubeseal"]
Expand Down
2 changes: 1 addition & 1 deletion registry/kubie.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
backends = ["aqua:sbstp/kubie", "asdf:johnhamelink/asdf-kubie"]
backends = ["aqua:kubie-org/kubie", "asdf:johnhamelink/asdf-kubie"]
bins = ["kubie"]
description = "A more powerful alternative to kubectx and kubens"
version_order = "semver"
2 changes: 1 addition & 1 deletion registry/mprocs.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
backends = ["aqua:pvolok/mprocs"]
backends = ["aqua:pvolok/dekit"]
bins = ["mprocs"]
description = "Run multiple commands in parallel"
test = { cmd = "mprocs --version", expected = "mprocs {{version}}" }
Expand Down
2 changes: 1 addition & 1 deletion registry/oauth2c.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
backends = ["aqua:cloudentity/oauth2c"]
backends = ["aqua:SecureAuthCorp/oauth2c"]
bins = ["oauth2c"]
description = "User-friendly OAuth2 CLI"
test = { cmd = "oauth2c version", expected = "oauth2c version {{version}}" }
Expand Down
2 changes: 1 addition & 1 deletion registry/tart.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
backends = ["aqua:cirruslabs/tart"]
backends = ["aqua:openai/tart"]
description = "macOS and Linux VMs on Apple Silicon to use in CI and other automations"
os = ["macos"]
test = { cmd = "tart --version", expected = "{{version}}" }
Expand Down
2 changes: 1 addition & 1 deletion registry/typstyle.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
backends = ["aqua:Enter-tainer/typstyle", "cargo:typstyle"]
backends = ["aqua:typstyle-rs/typstyle", "cargo:typstyle"]
bins = ["typstyle"]
description = "Beautiful and reliable typst code formatter"
test = { cmd = "typstyle --version | grep 'Version:' | awk '{print $2}'", expected = "{{version}}" }
Expand Down
2 changes: 1 addition & 1 deletion registry/velero.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
backends = ["aqua:vmware-tanzu/velero", "asdf:looztra/asdf-velero"]
backends = ["aqua:velero-io/velero", "asdf:looztra/asdf-velero"]
bins = ["velero"]
description = "Backup and migrate Kubernetes applications and their persistent volumes"
version_order = "semver"
14 changes: 14 additions & 0 deletions src/aqua/standard_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ fn baked_registry_file(package_id: &str) -> Option<&'static [u8]> {
.copied()
}

/// The package id an alias resolves to, or `None` for anything else.
pub fn canonical_package_id(package_id: &str) -> Option<&'static str> {
AQUA_STANDARD_REGISTRY_ALIASES.get(package_id).copied()
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down Expand Up @@ -107,6 +112,15 @@ mod tests {
assert_eq!(alias_package.repo_name, canonical_package.repo_name);
}

#[test]
fn test_canonical_package_id() {
assert_eq!(
canonical_package_id("Enter-tainer/typstyle"),
Some("typstyle-rs/typstyle")
);
assert_eq!(canonical_package_id("typstyle-rs/typstyle"), None);
}

#[test]
fn test_baked_registry_numeric_replacement_keys() {
let package = package("sharkdp/hyperfine").unwrap().unwrap();
Expand Down
32 changes: 30 additions & 2 deletions src/backend/aqua.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1944,17 +1944,33 @@ impl AquaBackend {

fn use_versions_host_for_github_metadata(&self, repo: &str) -> bool {
let full = self.ba.full_without_opts();
if !backend_arg_matches_registry_backend(&self.ba) && shorts_for_full(&full).is_empty() {
// aqua-registry keeps a renamed repo's old id as an alias, so an id from an older config
// or lockfile and `repo` can be one package spelled two ways.
let canonical_full = Self::canonical_aqua_backend(&full);
if !backend_arg_matches_registry_backend(&self.ba)
&& shorts_for_full(&full).is_empty()
&& shorts_for_full(&canonical_full).is_empty()
{
return false;
}
let Some(aqua_id) = full.strip_prefix("aqua:") else {
let Some(aqua_id) = canonical_full.strip_prefix("aqua:") else {
return false;
};
let aqua_id = aqua_id.to_ascii_lowercase();
let repo = repo.to_ascii_lowercase();
aqua_id == repo || aqua_id.starts_with(&format!("{repo}/"))
}

fn canonical_aqua_backend(full: &str) -> String {
let Some(aqua_id) = full.strip_prefix("aqua:") else {
return full.to_string();
};
match crate::aqua::standard_registry::canonical_package_id(aqua_id) {
Some(canonical) => format!("aqua:{canonical}"),
None => full.to_string(),
}
}

async fn get_github_release(&self, repo: &str, tag: &str) -> Result<github::GithubRelease> {
github::get_release_for_url_with_versions_host(
github::API_URL,
Expand Down Expand Up @@ -3664,6 +3680,18 @@ mod tests {
);
}

#[test]
fn test_use_versions_host_for_github_metadata_resolves_renamed_aqua_ids() {
// A mise.toml or lockfile pinned before the typstyle repo moved still names it this way.
let renamed_backend = AquaBackend::from_arg(BackendArg::new(
"typstyle".to_string(),
Some("aqua:Enter-tainer/typstyle".to_string()),
));
assert!(renamed_backend.use_versions_host_for_github_metadata("typstyle-rs/typstyle"));
// The id is resolved, `repo` is not.
assert!(!renamed_backend.use_versions_host_for_github_metadata("Enter-tainer/typstyle"));
}

#[test]
fn test_has_github_attestations_config_requires_enabled_config() {
let mut pkg = AquaPackage::default();
Expand Down
26 changes: 26 additions & 0 deletions src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1275,4 +1275,30 @@ idiomatic_files = [{ path = ".example-version", parser = "shell" }]
"https://github.com/attacker/vfox-cmake.git"
));
}

#[test]
fn aqua_backends_name_canonical_packages() {
let stale = super::baked_registry()
.iter()
.flat_map(|(short, tool)| {
tool.backends
.iter()
.map(move |backend| (short, backend.full))
})
.filter_map(|(short, full)| {
let id = full.strip_prefix("aqua:")?;
let id = id.split('[').next().unwrap_or(id);
let canonical = crate::aqua::standard_registry::canonical_package_id(id)?;
// The gate lowercases both sides, so a case-only alias still matches.
(!canonical.eq_ignore_ascii_case(id))
.then(|| format!(" registry/{short}.toml: aqua:{id} -> aqua:{canonical}"))
})
.collect::<Vec<_>>();

assert!(
stale.is_empty(),
"aqua backends naming a renamed package by its old id:\n{}",
stale.join("\n")
);
}
}