git_next_core/git/forge/
trait.rs1use crate::{
3 git, server::RepoListenUrl, webhook, ForgeNotification, RegisteredWebhook, WebhookAuth,
4 WebhookId,
5};
6
7#[mockall::automock]
8#[async_trait::async_trait]
9pub trait ForgeLike: std::fmt::Debug + Send + Sync {
10 fn duplicate(&self) -> Box<dyn ForgeLike>;
11 fn name(&self) -> String;
12
13 fn is_message_authorised(&self, message: &ForgeNotification, expected: &WebhookAuth) -> bool;
15
16 #[allow(unused_variables)]
20 fn should_ignore_message(&self, message: &ForgeNotification) -> bool {
21 false
22 }
23
24 fn parse_webhook_body(
30 &self,
31 body: &webhook::forge_notification::Body,
32 ) -> git::forge::webhook::Result<webhook::push::Push>;
33
34 async fn commit_status(
36 &self,
37 commit: &git::Commit,
38 ) -> git::forge::webhook::Result<git::forge::commit::Status>;
39
40 async fn list_webhooks(
42 &self,
43 repo_listen_url: &RepoListenUrl,
44 ) -> git::forge::webhook::Result<Vec<WebhookId>>;
45
46 async fn unregister_webhook(&self, webhook: &WebhookId) -> git::forge::webhook::Result<()>;
48
49 async fn register_webhook(
51 &self,
52 repo_listen_url: &RepoListenUrl,
53 ) -> git::forge::webhook::Result<RegisteredWebhook>;
54}