fix: normalize GitHub URLs ending in .git to not ending in .git (#1804)

* fix: normalize GitHub URLs ending in .git to not ending in .git

* Refactor `Data::get_repo_info`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix `get_repo_info` for repo with `.git` suffix

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Add e2e-tests to cover it

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Always try geting the redirected url

This would help:
 - redirect public gh repo `.git` to its canonical form
 - redirect public gh repo, which has been recently renamed
 - cases where redirection is needed to get the real repo

This commit make it fallbacks to the previou surl, if getting
the redirected url fail, in case the repository is private.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Add more e2e-tests

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Optimize: Do not try redirect if gh_get_repo_info fail

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Minor refactor

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

---------

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Kristof Mattei 2024-07-14 07:45:41 -07:00 committed by GitHub
parent 74af0e7f8a
commit fdfc89c287
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 106 additions and 43 deletions

View file

@ -1,7 +1,7 @@
[package]
name = "cargo-binstall"
description = "Rust binary package installer for CI integration"
repository = "https://gitlab.kitware.com/NobodyXu/hello-world"
repository = "https://gitlab.kitware.com/NobodyXu/hello-world.git"
version = "0.2.0"
rust-version = "1.61.0"
authors = ["ryan <ryan@kurte.nz>"]