cargo-bins / cargo-binstall

Binary installation for rust projects
GNU General Public License v3.0
1.64k stars 62 forks source link

fix: use the GhApiClient to normalize GitHub URLs #1803

Closed kristof-mattei closed 4 months ago

kristof-mattei commented 5 months ago

Closes #1801, see #1804 for alternative.

Test below: not added as it requires an internet connection, and it didn't seem sensible to mock out GhApiClient for this (or make it a trait):

    #[tokio::test]
    async fn test_ignore_dot_git_for_github_repos() {
        let url_without_git = "https://github.com/cargo-bins/cargo-binstall";
        let url_with_git = format!("{}.git", url_without_git);

        let data = Data::new("cargo-binstall".into(), "v1.2.3".into(), Some(url_with_git));

        let gh_client = GhApiClient::new(
            Client::new(
                "user-agent",
                None,
                NonZeroU16::new(1000).unwrap(),
                NonZeroU64::new(1000).unwrap(),
                [],
            )
            .unwrap(),
            None,
        );

        let repo_info = data.get_repo_info(&gh_client).await.unwrap().unwrap();

        assert_eq!(url_without_git, repo_info.repo.as_str());
    }
NobodyXu commented 4 months ago

Thanks, I prefer #1804 , closing this