From a4b71536852b53b27bb1ae6a212c556e5f01cec1 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Mon, 22 Jan 2024 17:23:56 +0100 Subject: [PATCH] Fix git urls without specifiers (#73) * Fix git urls without specifiers * Update CHANGELOG --- CHANGELOG.md | 3 +++ src/lib.rs | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2e0337..5200d23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate +### Fixed +- [PR#73](https://github.com/EmbarkStudios/krates/pull/73) resolved [#72](https://github.com/EmbarkStudios/krates/issues/72) by correctly parsing the new stable package ids where a specifier was not used. + ## [0.16.3] - 2024-01-22 ### Fixed - [PR#71](https://github.com/EmbarkStudios/krates/pull/71) fixed an issue introduced in [PR#70](https://github.com/EmbarkStudios/krates/pull/70) that would cause duplicates to not be detected correctly. Thanks [@louisdewar](https://github.com/louisdewar)! diff --git a/src/lib.rs b/src/lib.rs index eb0bdac..0e1d97f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -107,7 +107,7 @@ impl From for Kid { } else { let begin = repr.rfind('/')? + 1; let end = if repr.starts_with("git+") { - repr[begin..].find('?')? + begin + repr[begin..].find('?').map_or(vmn, |q| q + begin) } else { vmn }; @@ -748,11 +748,22 @@ mod tests { #[test] fn converts_package_ids() { let ids = [ + // STABLE + // A typical registry url, source, name, and version are always distinct ("registry+https://github.com/rust-lang/crates.io-index#ab_glyph@0.2.22", "ab_glyph", "0.2.22", "registry+https://github.com/rust-lang/crates.io-index"), + // A git url, with a `rev` specifier. For git urls, if the name of the package is the same as the last path component of the source, the name is not repeated after the #, only the version ("git+https://github.com/EmbarkStudios/egui-stylist?rev=3900e8aedc5801e42c1bb747cfd025615bf3b832#0.2.0", "egui-stylist", "0.2.0", "git+https://github.com/EmbarkStudios/egui-stylist?rev=3900e8aedc5801e42c1bb747cfd025615bf3b832"), + // The same as with git urls, the name is only after the # if it is different from the last path component ("path+file:///home/jake/code/ark/components/allocator#ark-allocator@0.1.0", "ark-allocator", "0.1.0", "path+file:///home/jake/code/ark/components/allocator"), + // A git url with a `branch` specifier ("git+https://github.com/EmbarkStudios/ash?branch=nv-low-latency2#0.38.0+1.3.269", "ash", "0.38.0+1.3.269", "git+https://github.com/EmbarkStudios/ash?branch=nv-low-latency2"), + // A git url with a `branch` specifier and a different name from the repo ("git+https://github.com/EmbarkStudios/fsr-rs?branch=nv-low-latency2#fsr@0.1.7", "fsr", "0.1.7", "git+https://github.com/EmbarkStudios/fsr-rs?branch=nv-low-latency2"), + // A git url that doesn't specify a branch, tag, or revision, defaulting to HEAD + ("git+https://github.com/ComunidadAylas/glsl-lang#0.5.2", "glsl-lang", "0.5.2", "git+https://github.com/ComunidadAylas/glsl-lang"), + // A git url that uses a `tag` specifier + ("git+https://github.com/vtavernier/glsl-lang?tag=v0.5.2#0.5.2", "glsl-lang", "0.5.2", "git+https://github.com/vtavernier/glsl-lang?tag=v0.5.2"), + // OPAQUE ("fuser 0.4.1 (git+https://github.com/cberner/fuser?branch=master#b2e7622942e52a28ffa85cdaf48e28e982bb6923)", "fuser", "0.4.1", "git+https://github.com/cberner/fuser?branch=master"), ("fuser 0.4.1 (git+https://github.com/cberner/fuser?rev=b2e7622#b2e7622942e52a28ffa85cdaf48e28e982bb6923)", "fuser", "0.4.1", "git+https://github.com/cberner/fuser?rev=b2e7622"), ("a 0.1.0 (path+file:///home/jake/code/krates/tests/ws/a)", "a", "0.1.0", "path+file:///home/jake/code/krates/tests/ws/a"),