Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Isolating test from accessing global git credential helper config#16895

Merged
konstin merged 3 commits into
astral-sh:mainfrom
sid-38:sid/unset-git-cred-helper
Dec 1, 2025
Merged

Isolating test from accessing global git credential helper config#16895
konstin merged 3 commits into
astral-sh:mainfrom
sid-38:sid/unset-git-cred-helper

Conversation

@sid-38

@sid-38 sid-38 commented Nov 30, 2025

Copy link
Copy Markdown
Contributor

Summary

Resolves: #1980

Added a utility function to TestContext called with_git_credential_helper_blocked that isolates the test from accessing the credential helper value defined in global/system git config. It does so, by writing to a file .gitconfig in the temporary home_dir that is created as part of the TestContext.

Test Plan

Tested it by running the test pip_install::install_git_private_https_pat_and_username, and making sure it doesn't affect the keyring.

Note:

The commit hash for the uv-private-package seems to have changed. Kindly, ensure that the modification related to that is correct.

Comment thread crates/uv/tests/it/common/mod.rs Outdated
Comment on lines +568 to +580
pub fn with_git_credential_helper_blocked(self) -> Self {
let path = self.home_dir.join(".gitconfig");
let mut file = fs_err::OpenOptions::new()
.create(true)
.append(true)
.open(&path)
.expect("Failed to open gitconfig file");

writeln!(file, "[credential]\n\thelper =\n")
.expect("Failed to write credential helper to gitconfig");

self
}

@samypr100 samypr100 Nov 30, 2025

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may be able to leverage the existing assert_fs support, e.g.

Suggested change
pub fn with_git_credential_helper_blocked(self) -> Self {
let path = self.home_dir.join(".gitconfig");
let mut file = fs_err::OpenOptions::new()
.create(true)
.append(true)
.open(&path)
.expect("Failed to open gitconfig file");
writeln!(file, "[credential]\n\thelper =\n")
.expect("Failed to write credential helper to gitconfig");
self
}
pub fn with_unset_git_credential_helper(self) -> Self {
let git_config = self.home_dir.child(".gitconfig");
git_config
.write_str(indoc! {r"
[credential]
helper =
"})
.expect("Failed to unset git credential helper");
self
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup that works. Made the change

@codspeed-hq

codspeed-hq Bot commented Dec 1, 2025

Copy link
Copy Markdown

CodSpeed Performance Report

Merging #16895 will degrade performances by 22.34%

Comparing sid-38:sid/unset-git-cred-helper (edca76d) with main (6d8866a)

Summary

❌ 1 regression
✅ 5 untouched

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Mode Benchmark BASE HEAD Change
Simulation resolve_warm_airflow 770.4 ms 992.1 ms -22.34%

@konstin konstin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this both on Windows and Linux.

Thank you!

@konstin konstin added the internal A refactor or improvement that is not user-facing label Dec 1, 2025
@konstin konstin merged commit 5773b12 into astral-sh:main Dec 1, 2025
101 of 102 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal A refactor or improvement that is not user-facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

install_git_private_https_pat_and_username breaks git

3 participants