forgejo-hooks: Add support for Issue
Signed-off-by: pep <pep@bouah.net>
This commit is contained in:
parent
5979b049f9
commit
a6195d68de
3 changed files with 307 additions and 32 deletions
|
|
@ -26,16 +26,6 @@ pub struct CommitAuthor {
|
|||
pub username: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
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, PartialEq)]
|
||||
pub struct Commit {
|
||||
pub id: String,
|
||||
|
|
@ -74,31 +64,17 @@ pub struct ExternalWiki {
|
|||
}
|
||||
|
||||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
pub struct Repository {
|
||||
pub struct RepositoryMeta {
|
||||
pub id: u64,
|
||||
pub owner: User,
|
||||
pub name: String,
|
||||
pub owner: 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: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
pub struct RepositoryFull {
|
||||
pub struct Repository {
|
||||
pub id: u64,
|
||||
pub owner: RepositoryOwner,
|
||||
pub owner: User,
|
||||
pub name: String,
|
||||
pub full_name: String,
|
||||
pub description: String,
|
||||
|
|
@ -159,7 +135,7 @@ pub struct RepositoryFull {
|
|||
}
|
||||
|
||||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
pub struct RepositoryOwner {
|
||||
pub struct User {
|
||||
pub id: u64,
|
||||
pub login: String,
|
||||
pub login_name: String,
|
||||
|
|
@ -210,7 +186,7 @@ pub struct AddedBranch {
|
|||
pub sha: String,
|
||||
pub ref_type: String,
|
||||
pub repository: Repository,
|
||||
pub sender: RepositoryOwner,
|
||||
pub sender: User,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
|
|
@ -219,7 +195,64 @@ pub struct RemovedBranch {
|
|||
pub ref_type: String,
|
||||
pub pusher_type: String,
|
||||
pub repository: Repository,
|
||||
pub sender: RepositoryOwner,
|
||||
pub sender: User,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum IssueAction {
|
||||
Opened,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum IssueState {
|
||||
Open,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
pub struct PullRequestMeta {
|
||||
pub merged: bool,
|
||||
pub merged_at: DateTime<Utc>,
|
||||
pub draft: bool,
|
||||
pub html_url: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
pub struct IssueAttrs {
|
||||
pub id: u32,
|
||||
pub url: String,
|
||||
pub html_url: String,
|
||||
pub number: u32,
|
||||
pub user: User,
|
||||
pub original_author: String,
|
||||
pub original_author_id: u32,
|
||||
pub title: String,
|
||||
pub body: String,
|
||||
#[serde(rename(deserialize = "ref"))]
|
||||
pub ref_: String,
|
||||
pub assets: Vec<String>,
|
||||
pub labels: Option<Vec<String>>,
|
||||
pub milestone: Option<String>,
|
||||
pub assignee: User,
|
||||
pub assignees: Vec<User>,
|
||||
pub state: IssueState,
|
||||
pub is_locked: bool,
|
||||
pub comments: u32,
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: Option<DateTime<Utc>>,
|
||||
pub closed_at: Option<DateTime<Utc>>,
|
||||
pub pull_request: Option<PullRequestMeta>,
|
||||
pub repository: RepositoryMeta,
|
||||
pub pin_order: u32,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
pub struct Issue {
|
||||
pub action: IssueAction,
|
||||
pub number: u64,
|
||||
pub issue: IssueAttrs,
|
||||
pub repository: Repository,
|
||||
}
|
||||
|
||||
impl From<Push> for Hook {
|
||||
|
|
@ -240,4 +273,5 @@ pub enum Hook {
|
|||
Push(Push),
|
||||
AddedBranch(AddedBranch),
|
||||
RemovedBranch(RemovedBranch),
|
||||
Issue(Issue),
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue