From b8ae4a3b6afe4f9bbe6a9b731f69b34b8af57a42 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:21:27 +0200 Subject: [PATCH] forgejo-hooks: Add support for branch pushes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- forgejo-hooks/src/lib.rs | 111 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 110 insertions(+), 1 deletion(-) diff --git a/forgejo-hooks/src/lib.rs b/forgejo-hooks/src/lib.rs index c8917a7..64e661a 100644 --- a/forgejo-hooks/src/lib.rs +++ b/forgejo-hooks/src/lib.rs @@ -28,6 +28,20 @@ pub struct Commit { pub timestamp: String, } +#[derive(Deserialize, Debug)] +pub struct Perms { + admin: bool, + push: bool, + pull: bool, +} + +#[derive(Deserialize, Debug)] +pub struct InternalTracker { + enable_time_tracker: bool, + allow_only_contributors_to_track_time: bool, + enable_issue_dependencies: bool +} + #[derive(Deserialize, Debug)] pub struct Repository { pub id: u32, @@ -51,7 +65,87 @@ pub struct Repository { } #[derive(Deserialize, Debug)] -pub struct Hook { +pub struct RepositoryFull { + pub id: u32, + pub owner: RepositoryOwner, + pub name: String, + pub full_name: String, + pub description: String, + pub empty: bool, + pub private: bool, + pub fork: bool, + pub template: bool, + pub parent: Option>, + pub mirror: bool, + pub size: u32, + pub language: String, + pub languages_url: String, + pub html_url: String, + pub url: String, + pub link: 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 open_pr_counter: u32, + pub default_branch: String, + pub created_at: String, + pub updated_at: String, + pub archived_at: String, + pub permissions: Perms, + pub has_issues: bool, + pub internal_tracker: InternalTracker, + pub has_wiki: bool, + pub has_pull_requests: bool, + pub has_projects: bool, + pub has_releases: bool, + pub has_actions: bool, + pub ignore_whitespace_conflicts: bool, + pub allow_merge_commits: bool, + pub allow_rebase: bool, + pub allow_rebase_explicit: bool, + pub allow_squash_merge: bool, + pub allow_rebase_update: bool, + pub default_delete_branch_after_merge: bool, + pub default_merge_style: String, + pub default_allow_maintainer_edit: bool, + pub avatar_url: String, + pub internal: bool, + pub mirror_internal: String, + pub mirror_updated: String, + pub repo_transfer: Option, +} + +#[derive(Deserialize, Debug)] +pub struct RepositoryOwner { + pub id: u32, + pub login: String, + pub login_name: String, + pub full_name: String, + pub email: String, + pub avatar_url: String, + pub language: String, + pub is_admin: bool, + pub last_login: String, + pub created: String, + pub restricted: bool, + pub active: bool, + pub prohibit_login: bool, + pub location: String, + pub website: String, + pub description: String, + pub visibility: String, + pub followers_count: u32, + pub following_count: u32, + pub starred_repos_count: u32, + pub username: String, +} + +#[derive(Deserialize, Debug)] +pub struct Push { #[serde(rename(deserialize = "ref"))] pub ref_: String, pub before: String, @@ -61,3 +155,18 @@ pub struct Hook { pub pusher: User, pub sender: User, } + +#[derive(Deserialize, Debug)] +pub struct Branch { + pub sha: String, + pub ref_type: String, + pub repository: Repository, + pub sender: RepositoryOwner, +} + +#[derive(Deserialize, Debug)] +#[serde(untagged)] +pub enum Hook { + Push(Push), + Branch(Branch), +}