chshersh / tool-sync

🧰 Download pre-built binaries of all your favourite tools with a single command
https://crates.io/crates/tool-sync
Mozilla Public License 2.0
69 stars 16 forks source link

[#69] Improves error message when the tag is not found #127

Closed crudiedo closed 1 year ago

crudiedo commented 1 year ago

Resolves #69

This PR improves error message when the tag is not found by adding new TagError error that displays a useful error message. Besides that, the error message may also display a suggestion (Did you mean?) by fetching the available tags and finding the similar one calculating Edit distance.

Additional tasks

chshersh commented 1 year ago

This PR will take a while for me to review due to the implementation complexity and the need to take multiple difficult decisions so I'm lowering its priority in favour of reviewing other PRs.

I've added the label though. Will get back to this PR later when I have enough time.

chshersh commented 1 year ago

My proposal is to wait for the implementation of #128 first to see how it affects the design of this issue. As mentioned before, we would like to avoid the total number of GitHub API queries. So a potential solution would be to query GitHub API again for the list of all releases if we don't find the specified tag.

As for the specific implementation of this issue, I propose the following weights for the Levenstein distance algorithm:

The idea behind this is to suggest similar tags. I think it would be weird to suggest version 7.8.9 when the user has specified 1.2.3. The common case is the absence or presence of the v prefix. Or a different minor version (e.g. 13.0.1 vs 13.1.0).

If there's no release within the edit distance threshold, we could just output all the possible releases with some of their info (e.g. the release date) so the users could select the desired release quickly.

crudiedo commented 1 year ago

Hey @chshersh,

I propose to drop that PR in favor of https://github.com/chshersh/tool-sync/pull/135 - even though showing the possible tag is cool, implementing it makes the codebase more complicated and unreadable.

The https://github.com/chshersh/tool-sync/pull/135 PR handles both "repo not found" and "tag not found" cases, so it'll be up to the user to check the available tags and choose the one they need.

chshersh commented 1 year ago

@crudiedo I agree with your assessment 🙂 Feel free to close this PR then 👍🏻

crudiedo commented 1 year ago

Closed due to https://github.com/chshersh/tool-sync/pull/135