1mod providers;
2
3use std::sync::Arc;
4
5use git::repository::GitRepository;
6use git::GitHostingProviderRegistry;
7use gpui::App;
8
9pub use crate::providers::*;
10
11/// Initializes the Git hosting providers.
12pub fn init(cx: &App) {
13 let provider_registry = GitHostingProviderRegistry::global(cx);
14 provider_registry.register_hosting_provider(Arc::new(Bitbucket));
15 provider_registry.register_hosting_provider(Arc::new(Chromium));
16 provider_registry.register_hosting_provider(Arc::new(Codeberg));
17 provider_registry.register_hosting_provider(Arc::new(Gitee));
18 provider_registry.register_hosting_provider(Arc::new(Github));
19 provider_registry.register_hosting_provider(Arc::new(Gitlab::new()));
20 provider_registry.register_hosting_provider(Arc::new(Sourcehut));
21}
22
23/// Registers additional Git hosting providers.
24///
25/// These require information from the Git repository to construct, so their
26/// registration is deferred until we have a Git repository initialized.
27pub fn register_additional_providers(
28 provider_registry: Arc<GitHostingProviderRegistry>,
29 repository: Arc<dyn GitRepository>,
30) {
31 let Some(origin_url) = repository.remote_url("origin") else {
32 return;
33 };
34
35 if let Ok(gitlab_self_hosted) = Gitlab::from_remote_url(&origin_url) {
36 provider_registry.register_hosting_provider(Arc::new(gitlab_self_hosted));
37 }
38}