Add a registry for GitHostingProvider
s (#11470)
This PR adds a registry for `GitHostingProvider`s. The intent here is to help decouple these provider-specific concerns from the lower-level `git` crate. Similar to languages, the Git hosting providers live in the new `git_hosting_providers` crate. This work also lays the foundation for if we wanted to allow defining a `GitHostingProvider` from within an extension. This could be useful if we wanted to extend the support to work with self-hosted Git providers (like GitHub Enterprise). I also took the opportunity to move some of the provider-specific code out of the `util` crate, since it had leaked into there. Release Notes: - N/A
This commit is contained in:
parent
a64e20ed96
commit
88c4e0b2d8
28 changed files with 405 additions and 229 deletions
|
@ -16,6 +16,7 @@ use editor::Editor;
|
|||
use env_logger::Builder;
|
||||
use fs::RealFs;
|
||||
use futures::{future, StreamExt};
|
||||
use git::GitHostingProviderRegistry;
|
||||
use gpui::{App, AppContext, AsyncAppContext, Context, Task, VisualContext};
|
||||
use image_viewer;
|
||||
use language::LanguageRegistry;
|
||||
|
@ -119,6 +120,7 @@ fn init_headless(dev_server_token: DevServerToken) {
|
|||
project::Project::init(&client, cx);
|
||||
client::init(&client, cx);
|
||||
|
||||
let git_hosting_provider_registry = GitHostingProviderRegistry::default_global(cx);
|
||||
let git_binary_path = if option_env!("ZED_BUNDLE").as_deref() == Some("true") {
|
||||
cx.path_for_auxiliary_executable("git")
|
||||
.context("could not find git binary path")
|
||||
|
@ -126,7 +128,9 @@ fn init_headless(dev_server_token: DevServerToken) {
|
|||
} else {
|
||||
None
|
||||
};
|
||||
let fs = Arc::new(RealFs::new(git_binary_path));
|
||||
let fs = Arc::new(RealFs::new(git_hosting_provider_registry, git_binary_path));
|
||||
|
||||
git_hosting_providers::init(cx);
|
||||
|
||||
let mut languages =
|
||||
LanguageRegistry::new(Task::ready(()), cx.background_executor().clone());
|
||||
|
@ -186,6 +190,7 @@ fn init_ui(args: Args) {
|
|||
let session_id = Uuid::new_v4().to_string();
|
||||
reliability::init_panic_hook(&app, installation_id.clone(), session_id.clone());
|
||||
|
||||
let git_hosting_provider_registry = Arc::new(GitHostingProviderRegistry::new());
|
||||
let git_binary_path = if option_env!("ZED_BUNDLE").as_deref() == Some("true") {
|
||||
app.path_for_auxiliary_executable("git")
|
||||
.context("could not find git binary path")
|
||||
|
@ -195,7 +200,10 @@ fn init_ui(args: Args) {
|
|||
};
|
||||
log::info!("Using git binary path: {:?}", git_binary_path);
|
||||
|
||||
let fs = Arc::new(RealFs::new(git_binary_path));
|
||||
let fs = Arc::new(RealFs::new(
|
||||
git_hosting_provider_registry.clone(),
|
||||
git_binary_path,
|
||||
));
|
||||
let user_settings_file_rx = watch_config_file(
|
||||
&app.background_executor(),
|
||||
fs.clone(),
|
||||
|
@ -236,6 +244,9 @@ fn init_ui(args: Args) {
|
|||
AppCommitSha::set_global(AppCommitSha(build_sha.into()), cx);
|
||||
}
|
||||
|
||||
GitHostingProviderRegistry::set_global(git_hosting_provider_registry, cx);
|
||||
git_hosting_providers::init(cx);
|
||||
|
||||
SystemAppearance::init(cx);
|
||||
OpenListener::set_global(listener.clone(), cx);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue