Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(aqua): apply override of version_prefix #4338

Merged
merged 5 commits into from
Feb 14, 2025

Conversation

risu729
Copy link
Contributor

@risu729 risu729 commented Feb 8, 2025

Partially resolves #3684.

This PR allows installing aqua:lycheeverse/[email protected], but ls-remote still prints lychee-v0.18.0. Furthermore, attempting to install aqua:lycheeverse/[email protected] fails.

I believe this will not affect other aqua packages, unless version_prefix is overridden.

@risu729 risu729 marked this pull request as draft February 8, 2025 03:38
@risu729
Copy link
Contributor Author

risu729 commented Feb 8, 2025

With #4340 merged, ls-remote prints 0.18.0 and use/install installs correctly at least for lychee.

However, mise use aqua:lycheeverse/[email protected] fails with the following error. This is not a bug but might be a breaking change.

Error: 
   0: failed to install aqua:lycheeverse/[email protected]
   1: HTTP status client error (404 Not Found) for url (https://api.github.com/repos/lycheeverse/lychee/releases/tags/lychee-lychee-v0.18.0)
   2: HTTP status client error (404 Not Found) for url (https://api.github.com/repos/lycheeverse/lychee/releases/tags/lychee-vlychee-v0.18.0)

jdx pushed a commit that referenced this pull request Feb 8, 2025
While I was debugging for #4338, I found that the `versions` crate
comparison logic was weird. It treated versions without prefixes larger
than versions with prefixes.

As documented in the code, it should be an expected behaviour, but since
many GitHub release tags contain prefixes, we should somehow trim them
before comparing versions.

> `nth_lenient` pulls a leading digit from the `Version`'s chunk if it
could. If it couldn't, that chunk is some string (perhaps a git hash)
and is considered as marking a beta/prerelease version. It is thus
considered less than the `SemVer`.

https://github.com/fosskers/rs-versions/blob/efb1b0d16418b17a774e3e5572815367bc813bcd/src/semver.rs#L124-L130

However, we need to parse `version_constraint` to get `version_prefix`
from `version_overrides`, so we cannot refer to the aqua registry to
determine the prefix of tags. This PR simply trims prefix-ish letters
(non-digit characters) from the version before comparison. It only trims
the prefix in `semver` function in `expr-lang`, so the effect should be
small.

Example of `versions` behaviour:
```rust
use versions::{Requirement, Versioning};
fn main() {
    let v = "test-0.2.0";
    let req = Requirement::new("<=0.1.0").unwrap();
    let ver = Versioning::new(v.strip_prefix('v').unwrap_or(v)).unwrap();
    println!("{:?}", req);
    println!("{:?}", ver);
    println!("{:?}", req.matches(&ver));
}
```
```
Requirement { op: LessEq, version: Some(Ideal(SemVer { major: 0, minor: 1, patch: 0, pre_rel: None, meta: None })) }
General(Version { epoch: None, chunks: Chunks([Alphanum("test")]), release: Some(Release([Numeric(0), Numeric(2), Numeric(0)])), meta: None })
true
```

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
@risu729 risu729 marked this pull request as ready for review February 9, 2025 10:09
@jdx jdx merged commit 8dda731 into jdx:main Feb 14, 2025
18 checks passed
jdx pushed a commit that referenced this pull request Feb 14, 2025
### 🚀 Features

- **(registry)** add e1s by
[@kiwamizamurai](https://github.com/kiwamizamurai) in
[#4363](#4363)
- **(registry)** add 'marksman' via 'aqua:artempyanykh/marksman' backend
by [@iamoeg](https://github.com/iamoeg) in
[#4357](#4357)
- use `machengine.org` for downloading nominated zig versions by
[@hadronomy](https://github.com/hadronomy) in
[#4356](#4356)

### 🐛 Bug Fixes

- **(aqua)** apply override of version_prefix by
[@risu729](https://github.com/risu729) in
[#4338](#4338)
- **(env_directive)** apply redactions only to env with redact by
[@risu729](https://github.com/risu729) in
[#4388](#4388)
- **(hook_env)** don't exit early if watching files are deleted by
[@risu729](https://github.com/risu729) in
[#4390](#4390)
- **(rubygems_plugin)** Replace which ruby check for Windows
compatibility by [@genskyff](https://github.com/genskyff) in
[#4358](#4358)
- lowercase desired shim names by
[@KevSlashNull](https://github.com/KevSlashNull) in
[#4333](#4333)
- allow cosign opts to be empty in aqua by
[@IxDay](https://github.com/IxDay) in
[#4396](#4396)

### 📚 Documentation

- update Fedora install for dnf5 by [@rkben](https://github.com/rkben)
in [#4387](#4387)
- fix links to idiomatic version file option by
[@pietrodn](https://github.com/pietrodn) in
[#4382](#4382)
- add mise bootstrap example in CI docs by
[@hverlin](https://github.com/hverlin) in
[#4351](#4351)
- Update link in comparison-to-asdf.md by
[@hverlin](https://github.com/hverlin) in
[#4401](#4401)

### 📦️ Dependency Updates

- update rust crate bzip2 to v0.5.1 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#4392](#4392)
- update rust crate built to v0.7.6 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#4391](#4391)

### Chore

- issue closer by [@jdx](https://github.com/jdx) in
[bee1f55](bee1f55)

### New Contributors

- @iamoeg made their first contribution in
[#4357](#4357)
- @hadronomy made their first contribution in
[#4356](#4356)
- @pietrodn made their first contribution in
[#4382](#4382)
- @genskyff made their first contribution in
[#4358](#4358)
- @kiwamizamurai made their first contribution in
[#4363](#4363)
- @rkben made their first contribution in
[#4387](#4387)
- @IxDay made their first contribution in
[#4396](#4396)
- @KevSlashNull made their first contribution in
[#4333](#4333)
@risu729 risu729 deleted the override-aqua-version-prefix branch February 15, 2025 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't install aqua:lycheeverse/[email protected]
2 participants