mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-06-16 15:46:36 +00:00
Fix v1 format for custom registry
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
e1ec8a21da
commit
8d85b37834
5 changed files with 40 additions and 4 deletions
|
@ -1,4 +1,4 @@
|
||||||
use std::{io, path::PathBuf, sync::Arc};
|
use std::{fmt::Display, io, path::PathBuf, sync::Arc};
|
||||||
|
|
||||||
use binstalk_downloader::remote::Client;
|
use binstalk_downloader::remote::Client;
|
||||||
use binstalk_types::cargo_toml_binstall::Meta;
|
use binstalk_types::cargo_toml_binstall::Meta;
|
||||||
|
@ -73,6 +73,10 @@ impl GitRegistry {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn url(&self) -> impl Display + '_ {
|
||||||
|
&self.0.url
|
||||||
|
}
|
||||||
|
|
||||||
/// WARNING: This is a blocking operation.
|
/// WARNING: This is a blocking operation.
|
||||||
fn find_crate_matched_ver(
|
fn find_crate_matched_ver(
|
||||||
repo: &Repository,
|
repo: &Repository,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
||||||
|
|
||||||
use std::{io, str::FromStr, sync::Arc};
|
use std::{fmt, io, str::FromStr, sync::Arc};
|
||||||
|
|
||||||
use base16::DecodeError as Base16DecodeError;
|
use base16::DecodeError as Base16DecodeError;
|
||||||
use binstalk_downloader::{
|
use binstalk_downloader::{
|
||||||
|
@ -197,6 +197,15 @@ impl Registry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for Registry {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
match self {
|
||||||
|
Registry::Git(registry) => fmt::Display::fmt(®istry.url(), f),
|
||||||
|
Registry::Sparse(registry) => fmt::Display::fmt(®istry.url(), f),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl FromStr for Registry {
|
impl FromStr for Registry {
|
||||||
type Err = InvalidRegistryError;
|
type Err = InvalidRegistryError;
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::fmt::Display;
|
||||||
|
|
||||||
use binstalk_downloader::remote::{Client, Error as RemoteError};
|
use binstalk_downloader::remote::{Client, Error as RemoteError};
|
||||||
use binstalk_types::cargo_toml_binstall::Meta;
|
use binstalk_types::cargo_toml_binstall::Meta;
|
||||||
use cargo_toml_workspace::cargo_toml::Manifest;
|
use cargo_toml_workspace::cargo_toml::Manifest;
|
||||||
|
@ -28,6 +30,10 @@ impl SparseRegistry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn url(&self) -> impl Display + '_ {
|
||||||
|
&self.url
|
||||||
|
}
|
||||||
|
|
||||||
async fn get_dl_template(&self, client: &Client) -> Result<&str, RegistryError> {
|
async fn get_dl_template(&self, client: &Client) -> Result<&str, RegistryError> {
|
||||||
self.dl_template
|
self.dl_template
|
||||||
.get_or_try_init(|| {
|
.get_or_try_init(|| {
|
||||||
|
|
|
@ -453,7 +453,17 @@ impl PackageInfo {
|
||||||
.fetch_crate_matched(client, &name, version_req),
|
.fetch_crate_matched(client, &name, version_req),
|
||||||
)
|
)
|
||||||
.await?,
|
.await?,
|
||||||
CrateSource::cratesio_registry(),
|
{
|
||||||
|
let registry = format!("{}", opts.registry);
|
||||||
|
if registry == "https://index.crates.io/" {
|
||||||
|
CrateSource::cratesio_registry()
|
||||||
|
} else {
|
||||||
|
CrateSource {
|
||||||
|
source_type: SourceType::Registry,
|
||||||
|
url: MaybeOwned::Owned(Url::parse(®istry)?),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -43,20 +43,27 @@ EOF
|
||||||
# Install binaries using default registry in config
|
# Install binaries using default registry in config
|
||||||
"./$1" binstall --force -y cargo-binstall@0.12.0
|
"./$1" binstall --force -y cargo-binstall@0.12.0
|
||||||
|
|
||||||
|
grep -F "cargo-binstall 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" <"$CARGO_HOME/.crates.toml"
|
||||||
|
|
||||||
test_cargo_binstall_install
|
test_cargo_binstall_install
|
||||||
|
|
||||||
# Install binaries using registry t2 in config
|
# Install binaries using registry t2 in config
|
||||||
"./$1" binstall --force --registry t2 -y cargo-binstall@0.12.0
|
"./$1" binstall --force --registry t2 -y cargo-binstall@0.12.0
|
||||||
|
|
||||||
|
grep -F "cargo-binstall 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" <"$CARGO_HOME/.crates.toml"
|
||||||
|
|
||||||
test_cargo_binstall_install
|
test_cargo_binstall_install
|
||||||
|
|
||||||
# Install binaries using registry t3 in env
|
# Install binaries using registry t3 in env
|
||||||
CARGO_REGISTRIES_t3_INDEX='sparse+https://index.crates.io/' "./$1" binstall --force --registry t3 -y cargo-binstall@0.12.0
|
CARGO_REGISTRIES_t3_INDEX='sparse+https://index.crates.io/' "./$1" binstall --force --registry t3 -y cargo-binstall@0.12.0
|
||||||
|
|
||||||
test_cargo_binstall_install
|
grep -F "cargo-binstall 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" <"$CARGO_HOME/.crates.toml"
|
||||||
|
|
||||||
|
test_cargo_binstall_install
|
||||||
|
|
||||||
# Install binaries using index directly
|
# Install binaries using index directly
|
||||||
"./$1" binstall --force --index 'sparse+https://index.crates.io/' -y cargo-binstall@0.12.0
|
"./$1" binstall --force --index 'sparse+https://index.crates.io/' -y cargo-binstall@0.12.0
|
||||||
|
|
||||||
|
grep -F "cargo-binstall 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" <"$CARGO_HOME/.crates.toml"
|
||||||
|
|
||||||
test_cargo_binstall_install
|
test_cargo_binstall_install
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue