Allow configuring custom git hosting providers in project settings (#31929)

Closes #29229

Release Notes:

- Extended the support for configuring custom git hosting providers to
cover project settings in addition to global settings.

---------

Co-authored-by: Anthony Eid <hello@anthonyeid.me>
This commit is contained in:
Cole Miller 2025-06-03 12:23:01 -04:00 committed by GitHub
parent 203754d0db
commit 1307b81721
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 138 additions and 20 deletions

View file

@ -11,6 +11,7 @@ use buffer_diff::{
use fs::FakeFs;
use futures::{StreamExt, future};
use git::{
GitHostingProviderRegistry,
repository::RepoPath,
status::{StatusCode, TrackedStatus},
};
@ -216,6 +217,71 @@ async fn test_editorconfig_support(cx: &mut gpui::TestAppContext) {
});
}
#[gpui::test]
async fn test_git_provider_project_setting(cx: &mut gpui::TestAppContext) {
init_test(cx);
cx.update(|cx| {
GitHostingProviderRegistry::default_global(cx);
git_hosting_providers::init(cx);
});
let fs = FakeFs::new(cx.executor());
let str_path = path!("/dir");
let path = Path::new(str_path);
fs.insert_tree(
path!("/dir"),
json!({
".zed": {
"settings.json": r#"{
"git_hosting_providers": [
{
"provider": "gitlab",
"base_url": "https://google.com",
"name": "foo"
}
]
}"#
},
}),
)
.await;
let project = Project::test(fs.clone(), [path!("/dir").as_ref()], cx).await;
let (_worktree, _) =
project.read_with(cx, |project, cx| project.find_worktree(path, cx).unwrap());
cx.executor().run_until_parked();
cx.update(|cx| {
let provider = GitHostingProviderRegistry::global(cx);
assert!(
provider
.list_hosting_providers()
.into_iter()
.any(|provider| provider.name() == "foo")
);
});
fs.atomic_write(
Path::new(path!("/dir/.zed/settings.json")).to_owned(),
"{}".into(),
)
.await
.unwrap();
cx.run_until_parked();
cx.update(|cx| {
let provider = GitHostingProviderRegistry::global(cx);
assert!(
!provider
.list_hosting_providers()
.into_iter()
.any(|provider| provider.name() == "foo")
);
});
}
#[gpui::test]
async fn test_managing_project_specific_settings(cx: &mut gpui::TestAppContext) {
init_test(cx);