Use URL rather than String in direct URL types (#643)

This commit is contained in:
Charlie Marsh 2023-12-13 20:01:27 -05:00 committed by GitHub
parent 8071a23863
commit 4fd69c74b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View file

@ -130,7 +130,7 @@ impl TryFrom<&LocalFileUrl> for pypi_types::DirectUrl {
fn try_from(value: &LocalFileUrl) -> Result<Self, Self::Error> {
Ok(pypi_types::DirectUrl::LocalDirectory {
url: value.url.to_string(),
url: value.url.clone(),
dir_info: pypi_types::DirInfo { editable: None },
})
}
@ -141,7 +141,7 @@ impl TryFrom<&DirectArchiveUrl> for pypi_types::DirectUrl {
fn try_from(value: &DirectArchiveUrl) -> Result<Self, Self::Error> {
Ok(pypi_types::DirectUrl::ArchiveUrl {
url: value.url.to_string(),
url: value.url.clone(),
archive_info: pypi_types::ArchiveInfo {
hash: None,
hashes: None,
@ -156,7 +156,7 @@ impl TryFrom<&DirectGitUrl> for pypi_types::DirectUrl {
fn try_from(value: &DirectGitUrl) -> Result<Self, Self::Error> {
Ok(pypi_types::DirectUrl::VcsUrl {
url: value.url.repository().to_string(),
url: value.url.repository().clone(),
vcs_info: pypi_types::VcsInfo {
vcs: pypi_types::VcsKind::Git,
commit_id: value.url.precise().as_ref().map(ToString::to_string),

View file

@ -2,6 +2,7 @@ use std::collections::HashMap;
use std::path::PathBuf;
use serde::{Deserialize, Serialize};
use url::Url;
/// Metadata for a distribution that was installed via a direct URL.
///
@ -13,13 +14,13 @@ pub enum DirectUrl {
/// ```json
/// {"url": "file:///home/user/project", "dir_info": {}}
/// ```
LocalDirectory { url: String, dir_info: DirInfo },
LocalDirectory { url: Url, dir_info: DirInfo },
/// The direct URL is a path to an archive. For example:
/// ```json
/// {"archive_info": {"hash": "sha256=75909db2664838d015e3d9139004ee16711748a52c8f336b52882266540215d8", "hashes": {"sha256": "75909db2664838d015e3d9139004ee16711748a52c8f336b52882266540215d8"}}, "url": "https://files.pythonhosted.org/packages/b8/8b/31273bf66016be6ad22bb7345c37ff350276cfd46e389a0c2ac5da9d9073/wheel-0.41.2-py3-none-any.whl"}
/// ```
ArchiveUrl {
url: String,
url: Url,
archive_info: ArchiveInfo,
#[serde(skip_serializing_if = "Option::is_none")]
subdirectory: Option<PathBuf>,
@ -29,7 +30,7 @@ pub enum DirectUrl {
/// {"url": "https://github.com/pallets/flask.git", "vcs_info": {"commit_id": "8d9519df093864ff90ca446d4af2dc8facd3c542", "vcs": "git"}}
/// ```
VcsUrl {
url: String,
url: Url,
vcs_info: VcsInfo,
#[serde(skip_serializing_if = "Option::is_none")]
subdirectory: Option<PathBuf>,