forgejo-hooks: Add support for branch pushes

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2024-04-23 17:21:27 +02:00
parent b9b0303e88
commit b8ae4a3b6a
Signed by: pep
GPG key ID: DEDA74AEECA9D0F2

View file

@ -28,6 +28,20 @@ pub struct Commit {
pub timestamp: String, 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)] #[derive(Deserialize, Debug)]
pub struct Repository { pub struct Repository {
pub id: u32, pub id: u32,
@ -51,7 +65,87 @@ pub struct Repository {
} }
#[derive(Deserialize, Debug)] #[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<Box<RepositoryFull>>,
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<String>,
}
#[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"))] #[serde(rename(deserialize = "ref"))]
pub ref_: String, pub ref_: String,
pub before: String, pub before: String,
@ -61,3 +155,18 @@ pub struct Hook {
pub pusher: User, pub pusher: User,
pub sender: 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),
}