Skip to content

Commit d176fa6

Browse files
committed
Fixup
1 parent befb4da commit d176fa6

File tree

4 files changed

+25
-34
lines changed

4 files changed

+25
-34
lines changed

crates/cache-key/src/canonical_url.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,6 @@ impl RepositoryUrl {
117117
}
118118
}
119119

120-
// If using HTTPS, treat a username as a PAT
121-
if url.scheme().starts_with("https")
122-
&& immutable_url.password().is_none()
123-
&& !immutable_url.username().is_empty()
124-
{
125-
url.set_password(Some(immutable_url.username())).unwrap();
126-
url.set_username("").unwrap();
127-
}
128-
129120
// Drop any fragments and query parameters.
130121
url.set_fragment(None);
131122
url.set_query(None);

crates/uv-git/src/git.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,10 @@ where
682682
if allowed.contains(git2::CredentialType::USER_PASS_PLAINTEXT) && cred_helper_bad.is_none()
683683
{
684684
let r = git2::Cred::credential_helper(cfg, url, username);
685+
dbg!(url, username);
686+
if let Ok(ref r) = r {
687+
dbg!(r.has_username());
688+
}
685689
cred_helper_bad = Some(r.is_err());
686690
return r;
687691
}

crates/uv-git/src/lib.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,6 @@ impl TryFrom<Url> for GitUrl {
7373
url.set_path(prefix);
7474
}
7575

76-
// If using HTTPS, treat a username as a PAT
77-
if url.scheme().starts_with("https")
78-
&& immutable_url.password().is_none()
79-
&& !immutable_url.username().is_empty()
80-
{
81-
url.set_password(Some(immutable_url.username())).unwrap();
82-
url.set_username("").unwrap();
83-
}
84-
8576
let precise = if let GitReference::FullCommit(rev) = &reference {
8677
Some(GitSha::from_str(rev)?)
8778
} else {

crates/uv/tests/pip_install.rs

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use assert_cmd::prelude::*;
77
use assert_fs::prelude::*;
88
use base64::{prelude::BASE64_STANDARD as base64, Engine};
99
use indoc::indoc;
10+
use itertools::Itertools;
1011
use url::Url;
1112

1213
use common::{uv_snapshot, TestContext, EXCLUDE_NEWER, INSTA_FILTERS};
@@ -16,12 +17,19 @@ use crate::common::get_bin;
1617
mod common;
1718

1819
// This is a fine-grained token that only has read-only access to the `uv-private-pypackage` repository
19-
const READ_ONLY_GITHUB_TOKEN: &str = "MTFCR0laQTdRMEg1MnNYbEJ1Mlg5TF90VU1keWNCYzFvb2psRm9UbEVVYTJEbW54VkhPUXJqaGhRT1UwQVdZV2p0T0wyWlBJM0UzdlFvUmE3eA==";
20-
21-
fn decode_token(content: &str) -> String {
22-
let decoded = base64.decode(content).unwrap();
23-
let mut token = std::str::from_utf8(decoded.as_slice()).unwrap().to_string();
24-
token.insert_str(0, "gitub_pat_");
20+
const READ_ONLY_GITHUB_TOKEN: &[&str] = &[
21+
"Z2l0aHViX3BhdA==",
22+
"MTFCR0laQTdRMGdXeGsweHV6ekR2Mg==",
23+
"NVZMaExzZmtFMHZ1ZEVNd0pPZXZkV040WUdTcmk2WXREeFB4TFlybGlwRTZONEpHV01FMnFZQWJVUm4=",
24+
];
25+
26+
/// Decode a
27+
fn decode_token(content: &[&str]) -> String {
28+
let token = content
29+
.iter()
30+
.map(|part| base64.decode(part).unwrap())
31+
.map(|decoded| std::str::from_utf8(decoded.as_slice()).unwrap().to_string())
32+
.join("_");
2533
token
2634
}
2735

@@ -763,7 +771,7 @@ fn install_git_private_https_pat() {
763771
Resolved 1 package in [TIME]
764772
Downloaded 1 package in [TIME]
765773
Installed 1 package in [TIME]
766-
+ uv-private-pypackage==0.1.0 (from git+https://:***@github.com/astral-test/uv-private-pypackage@6c09ce9ae81f50670a60abd7d95f30dd416d00ac)
774+
+ uv-private-pypackage==0.1.0 (from git+https://***@github.com/astral-test/uv-private-pypackage@6c09ce9ae81f50670a60abd7d95f30dd416d00ac)
767775
"###);
768776

769777
context.assert_installed("uv_private_pypackage", "0.1.0");
@@ -784,18 +792,15 @@ fn install_git_private_https_pat_and_username() {
784792
uv_snapshot!(filters, command(&context)
785793
.arg(format!("uv-private-pypackage @ git+https://{user}:{token}@github.com/astral-test/uv-private-pypackage"))
786794
, @r###"
787-
success: false
788-
exit_code: 2
795+
success: true
796+
exit_code: 0
789797
----- stdout -----
790798
791799
----- stderr -----
792-
error: Failed to download and build: uv-private-pypackage @ git+https://astral-test-bot:***@github.com/astral-test/uv-private-pypackage
793-
Caused by: Git operation failed
794-
Caused by: failed to clone into: [PATH]
795-
Caused by: failed to authenticate when downloading repository
796-
797-
* attempted to find username/password via `credential.helper`, but maybe the found credentials were incorrect
798-
Caused by: no authentication methods succeeded
800+
Resolved 1 package in [TIME]
801+
Downloaded 1 package in [TIME]
802+
Installed 1 package in [TIME]
803+
+ uv-private-pypackage==0.1.0 (from git+https://astral-test-bot:***@github.com/astral-test/uv-private-pypackage@6c09ce9ae81f50670a60abd7d95f30dd416d00ac)
799804
"###);
800805

801806
context.assert_installed("uv_private_pypackage", "0.1.0");

0 commit comments

Comments
 (0)