From 3a371f9cfb65902c4ef9d8743d50113add3680c2 Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Thu, 7 Nov 2024 10:36:35 -0500 Subject: [PATCH 1/9] chore: accept path `AsRef` --- workspace/gh-workflow/src/generate.rs | 10 +++++----- workspace/gh-workflow/src/workflow.rs | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/workspace/gh-workflow/src/generate.rs b/workspace/gh-workflow/src/generate.rs index 6013cf0..8be7093 100644 --- a/workspace/gh-workflow/src/generate.rs +++ b/workspace/gh-workflow/src/generate.rs @@ -1,21 +1,21 @@ -use std::path::Path; +use std::path::{Path, PathBuf}; use crate::error::{Error, Result}; use crate::Workflow; pub struct Generate { workflow: Workflow, - path: String, + path: PathBuf, } impl Generate { - pub fn new(workflow: Workflow, path: P) -> Self { - Self { workflow, path: path.to_string() } + pub fn new>(workflow: Workflow, path: P) -> Self { + Self { workflow, path: path.as_ref().to_path_buf() } } pub fn generate(&self) -> Result<()> { let comment = include_str!("./comment.yml"); - let path = Path::new(self.path.as_str()); + let path = self.path.as_path(); path.parent() .map_or(Ok(()), std::fs::create_dir_all) diff --git a/workspace/gh-workflow/src/workflow.rs b/workspace/gh-workflow/src/workflow.rs index a2c843f..41265fd 100644 --- a/workspace/gh-workflow/src/workflow.rs +++ b/workspace/gh-workflow/src/workflow.rs @@ -1,6 +1,7 @@ #![allow(clippy::needless_update)] use std::fmt::Display; +use std::path::Path; use derive_setters::Setters; use indexmap::IndexMap; @@ -71,7 +72,7 @@ impl Workflow { Ok(serde_yaml::from_str(yml)?) } - pub fn generate(self, path: T) -> Result<()> { + pub fn generate>(self, path: T) -> Result<()> { Generate::new(self, path).generate() } From 1c5f0f35a9c3d55914bc597cfeaa493082eed790 Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Thu, 7 Nov 2024 11:43:22 -0500 Subject: [PATCH 2/9] chore: populate Events --- workspace/gh-workflow/src/event.rs | 852 ++++++++++++++++++++++++++++- 1 file changed, 835 insertions(+), 17 deletions(-) diff --git a/workspace/gh-workflow/src/event.rs b/workspace/gh-workflow/src/event.rs index f630771..0f18c1a 100644 --- a/workspace/gh-workflow/src/event.rs +++ b/workspace/gh-workflow/src/event.rs @@ -1,4 +1,6 @@ +use std::fmt::{Display, Formatter}; use derive_setters::Setters; +use indexmap::IndexMap; use serde::Serialize; use crate::SetEvent; @@ -9,19 +11,573 @@ use crate::SetEvent; pub struct Event { pub push: Option, pub pull_request: Option, - // TODO: add all more events + pub branch_protection_rule: Option, + pub check_run: Option, + pub check_suite: Option, + pub create: Option, + pub delete: Option, + pub deployment: Option, + pub deployment_status: Option, + pub discussion: Option, + pub discussion_comment: Option, + pub fork: Option, + pub gollum: Option, + pub issue_comment: Option, + pub issues: Option, + pub label: Option