From c08dfb9965d56b44b5ae9bcbd95120c5cf38fbd3 Mon Sep 17 00:00:00 2001 From: daimond113 <72147841+daimond113@users.noreply.github.com> Date: Wed, 4 Sep 2024 16:19:09 +0200 Subject: [PATCH] feat(registry): use env variable for repo --- registry/.env.example | 2 ++ registry/src/endpoints/publish_version.rs | 6 +++--- registry/src/main.rs | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/registry/.env.example b/registry/.env.example index 1a25b56..dba0403 100644 --- a/registry/.env.example +++ b/registry/.env.example @@ -1,3 +1,5 @@ +INDEX_REPO_URL = # url of the index repository + GITHUB_USERNAME= # username of github account with push access to the index repository GITHUB_PAT= # personal access token of github account with push access to the index repository diff --git a/registry/src/endpoints/publish_version.rs b/registry/src/endpoints/publish_version.rs index 365feed..114ed1d 100644 --- a/registry/src/endpoints/publish_version.rs +++ b/registry/src/endpoints/publish_version.rs @@ -288,10 +288,10 @@ pub async fn publish_package( DependencySpecifiers::Pesde(specifier) => { if specifier .index - .as_ref() - .filter(|index| match index.parse::() { + .as_deref() + .filter(|index| match gix::Url::try_from(*index) { Ok(_) if config.other_registries_allowed => true, - Ok(url) => url == env!("CARGO_PKG_REPOSITORY").parse().unwrap(), + Ok(url) => url == *source.repo_url(), Err(_) => false, }) .is_none() diff --git a/registry/src/main.rs b/registry/src/main.rs index c48fe07..7d4c30e 100644 --- a/registry/src/main.rs +++ b/registry/src/main.rs @@ -85,7 +85,7 @@ async fn run(with_sentry: bool) -> std::io::Result<()> { password: benv!(required "GITHUB_PAT"), })), ); - let source = PesdePackageSource::new(env!("CARGO_PKG_REPOSITORY").try_into().unwrap()); + let source = PesdePackageSource::new(benv!(required "INDEX_REPO_URL").try_into().unwrap()); source.refresh(&project).expect("failed to refresh source"); let (search_reader, search_writer) = make_search(&project, &source);