From b9b0303e88f4216d0f537610028cfae6a2ca4cb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Tue, 23 Apr 2024 17:19:47 +0200 Subject: [PATCH] Sub-crate: forgejo-hooks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Supports commit push for the moment Signed-off-by: Maxime “pep” Buquet --- forgejo-hooks/Cargo.toml | 7 +++++ forgejo-hooks/src/lib.rs | 63 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 forgejo-hooks/Cargo.toml create mode 100644 forgejo-hooks/src/lib.rs diff --git a/forgejo-hooks/Cargo.toml b/forgejo-hooks/Cargo.toml new file mode 100644 index 0000000..2b8444e --- /dev/null +++ b/forgejo-hooks/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "forgejo-hooks" +version = "0.1.0" +edition = "2021" + +[dependencies] +serde = { version = "1.0", features = ["derive"] } diff --git a/forgejo-hooks/src/lib.rs b/forgejo-hooks/src/lib.rs new file mode 100644 index 0000000..c8917a7 --- /dev/null +++ b/forgejo-hooks/src/lib.rs @@ -0,0 +1,63 @@ + +use serde::Deserialize; + +#[derive(Deserialize, Debug)] +pub struct CommitAuthor { + pub name: String, + pub email: String, + pub username: String, +} + +#[derive(Deserialize, Debug)] +pub struct User { + pub id: u32, + pub login: String, + pub full_name: String, + pub email: String, + pub avatar_url: String, + pub username: String, +} + +#[derive(Deserialize, Debug)] +pub struct Commit { + pub id: String, + pub message: String, + pub url: String, + pub author: CommitAuthor, + pub committer: CommitAuthor, + pub timestamp: String, +} + +#[derive(Deserialize, Debug)] +pub struct Repository { + pub id: u32, + pub owner: User, + pub name: String, + pub full_name: String, + pub description: String, + pub private: bool, + pub fork: bool, + pub html_url: String, + pub ssh_url: String, + pub clone_url: String, + pub website: String, + pub stars_count: u32, + pub forks_count: u32, + pub watchers_count: u32, + pub open_issues_count: u32, + pub default_branch: String, + pub created_at: String, + pub updated_at: String, +} + +#[derive(Deserialize, Debug)] +pub struct Hook { + #[serde(rename(deserialize = "ref"))] + pub ref_: String, + pub before: String, + pub compare_url: String, + pub commits: Vec, + pub repository: Repository, + pub pusher: User, + pub sender: User, +}