67 lines
3.4 KiB
Rust
67 lines
3.4 KiB
Rust
//
|
|
use config::newtype;
|
|
use derive_more::Display;
|
|
|
|
use git::UserNotification;
|
|
use git_next_actor_macros::message;
|
|
use git_next_config as config;
|
|
use git_next_git as git;
|
|
|
|
message!(LoadConfigFromRepo: "Request to load the `git-next.toml` from the git repo.");
|
|
message!(CloneRepo: "Request to clone (or open) the git repo.");
|
|
message!(ReceiveRepoConfig: config::RepoConfig: r#"Notification that the `git-next.toml` file has been loaded from the repo and parsed.
|
|
|
|
Contains the parsed contents of the `git-next.toml` file."#);
|
|
message!(ValidateRepo: MessageToken: r#"Request that the state of the branches in the git repo be assessed and generate any followup actions.
|
|
|
|
This is the main function of `git-next` where decisions are made on what branches need to be updated and when.
|
|
|
|
Contains a [MessageToken] to reduce duplicate messages being sent. Only messages with the latest [MessageToken] are handled,
|
|
all others are dropped."#);
|
|
|
|
message!(WebhookRegistered: (config::WebhookId, config::WebhookAuth): r#"Notification that a webhook has been registered with a forge.
|
|
|
|
Contains a tuple of the ID for the webhook returned from the forge, and the unique authorisation token that
|
|
incoming messages from the forge must provide."#);
|
|
impl WebhookRegistered {
|
|
pub const fn webhook_id(&self) -> &config::WebhookId {
|
|
&self.0 .0
|
|
}
|
|
pub const fn webhook_auth(&self) -> &config::WebhookAuth {
|
|
&self.0 .1
|
|
}
|
|
}
|
|
impl From<config::RegisteredWebhook> for WebhookRegistered {
|
|
fn from(value: config::RegisteredWebhook) -> Self {
|
|
let webhook_id = value.id().clone();
|
|
let webhook_auth = value.auth().clone();
|
|
Self::from((webhook_id, webhook_auth))
|
|
}
|
|
}
|
|
|
|
message!(UnRegisterWebhook: "Request that the webhook be removed from the forge, so they will stop notifying us.");
|
|
|
|
newtype!(MessageToken: u32, Copy, Default, Display, PartialOrd, Ord: r#"An incremental token used to identify the current set of messages.
|
|
|
|
Primarily used by [ValidateRepo] to reduce duplicate messages. The token is incremented when a new Webhook message is
|
|
received, marking that message the latest, and causing any previous messages still being processed to be dropped when
|
|
they next send a [ValidateRepo] message."#);
|
|
impl MessageToken {
|
|
pub const fn next(&self) -> Self {
|
|
Self(self.0 + 1)
|
|
}
|
|
}
|
|
|
|
message!(RegisterWebhook: "Requests that a Webhook be registered with the forge.");
|
|
message!(CheckCIStatus: git::Commit: r#"Requests that the CI status for the commit be checked.
|
|
|
|
Once the CI Status has been received it will be sent via a [ReceiveCIStatus] message.
|
|
|
|
Contains the commit from the tip of the `next` branch."#); // next commit
|
|
message!(ReceiveCIStatus: (git::Commit, git::forge::commit::Status): r#"Notification of the status of the CI checks for the commit.
|
|
|
|
Contains a tuple of the commit that was checked (the tip of the `next` branch) and the status."#); // commit and it's status
|
|
message!(AdvanceNext: (git::Commit, Vec<git::Commit>): "Request to advance the `next` branch on to the next commit on the `dev branch."); // next commit and the dev commit history
|
|
message!(AdvanceMain: git::Commit: "Request to advance the `main` branch on to same commit as the `next` branch."); // next commit
|
|
message!(WebhookNotification: config::webhook::forge_notification::ForgeNotification: "Notification of a webhook message from the forge.");
|
|
message!(NotifyUser: UserNotification: "Request to send the message payload to the notification webhook");
|