ZIm/crates/git_hosting_providers/src/git_hosting_providers.rs
Henrique Ferreiro ec00fb97fd
git_hosting_providers: Add support for Chromium repositories (#24881)
Add an implementation of GitHostingProvider for repositories hosted on
https://chromium.googlesource.com. Pull requests target the Gerrit
instance at https://chromium-review.googlesource.com and avatar images
are fetched using the Gerrit REST API.

<img width="513" alt="Screenshot 2025-02-20 at 6 43 37 PM"
src="https://github.com/user-attachments/assets/867af988-594d-45ea-8482-e40517443c73"
/>

<img width="511" alt="Screenshot 2025-02-20 at 6 43 51 PM"
src="https://github.com/user-attachments/assets/1d412904-048d-4a2d-8494-0837e75f8d61"
/>

Release Notes:

- Added support for repositories hosted on `chromium.googlesource.com`
for Git blames and permalinks.

---------

Co-authored-by: Marshall Bowers <git@maxdeviant.com>
2025-02-20 19:11:32 -05:00

38 lines
1.3 KiB
Rust

mod providers;
use std::sync::Arc;
use git::repository::GitRepository;
use git::GitHostingProviderRegistry;
use gpui::App;
pub use crate::providers::*;
/// Initializes the Git hosting providers.
pub fn init(cx: &App) {
let provider_registry = GitHostingProviderRegistry::global(cx);
provider_registry.register_hosting_provider(Arc::new(Bitbucket));
provider_registry.register_hosting_provider(Arc::new(Chromium));
provider_registry.register_hosting_provider(Arc::new(Codeberg));
provider_registry.register_hosting_provider(Arc::new(Gitee));
provider_registry.register_hosting_provider(Arc::new(Github));
provider_registry.register_hosting_provider(Arc::new(Gitlab::new()));
provider_registry.register_hosting_provider(Arc::new(Sourcehut));
}
/// Registers additional Git hosting providers.
///
/// These require information from the Git repository to construct, so their
/// registration is deferred until we have a Git repository initialized.
pub fn register_additional_providers(
provider_registry: Arc<GitHostingProviderRegistry>,
repository: Arc<dyn GitRepository>,
) {
let Some(origin_url) = repository.remote_url("origin") else {
return;
};
if let Ok(gitlab_self_hosted) = Gitlab::from_remote_url(&origin_url) {
provider_registry.register_hosting_provider(Arc::new(gitlab_self_hosted));
}
}