Add support for ForgejoHook::Issue
Signed-off-by: pep <pep@bouah.net>
This commit is contained in:
parent
468b42abfd
commit
fc0b13079f
1 changed files with 29 additions and 2 deletions
|
@ -13,10 +13,36 @@
|
|||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::hooks::types::{Commit, Hook, Push, Repository, User};
|
||||
use crate::hooks::types::{Commit, Hook, Issue, IssueAction, Push, Repository, User};
|
||||
use crate::Error;
|
||||
|
||||
pub use ::forgejo_hooks::Hook as ForgejoHook;
|
||||
pub use ::forgejo_hooks::{Hook as ForgejoHook, Issue as FjIssue, IssueAction as FjIssueAction};
|
||||
|
||||
impl From<FjIssueAction> for IssueAction {
|
||||
fn from(other: FjIssueAction) -> IssueAction {
|
||||
match other {
|
||||
FjIssueAction::Opened => IssueAction::Open,
|
||||
FjIssueAction::Edited => IssueAction::Update,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<FjIssue> for Issue {
|
||||
fn from(other: FjIssue) -> Issue {
|
||||
Issue {
|
||||
id: other.number,
|
||||
action: Some(other.action.into()),
|
||||
title: other.issue.title,
|
||||
author: User {
|
||||
name: other.issue.user.login,
|
||||
},
|
||||
repository: Repository {
|
||||
name: other.repository.name,
|
||||
},
|
||||
url: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<ForgejoHook> for Hook {
|
||||
type Error = Error;
|
||||
|
@ -42,6 +68,7 @@ impl TryFrom<ForgejoHook> for Hook {
|
|||
name: push.pusher.username,
|
||||
},
|
||||
}),
|
||||
ForgejoHook::Issue(issue) => Hook::Issue(issue.into()),
|
||||
_ => return Err(Error::UnsupportedHookConversion),
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue