From 6f44c872a347907737cc1d2f9e49da201142044e Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Sun, 21 May 2023 11:21:01 +0000 Subject: merge, patch, pull requests and repo_config --- src/pull_request.rs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/pull_request.rs (limited to 'src/pull_request.rs') diff --git a/src/pull_request.rs b/src/pull_request.rs new file mode 100644 index 0000000..a87fa45 --- /dev/null +++ b/src/pull_request.rs @@ -0,0 +1,39 @@ +use nostr::{Event, EventBuilder, Keys }; + + +use crate::{ngit_tag::{tag_repo, tag_branch, tag_branch_merge_from, tag_hashtag, tag_into_event}, kind::Kind}; + +pub fn initialize_pull_request( + keys: &Keys, + repoistory:&String, + to_branch_id: &String, + from_branch_id: &String, + title: &String, + description: &String, + hashtags: Vec, + +) -> Event { + let mut tags = vec![ + tag_repo(repoistory), + tag_into_event(tag_repo(repoistory)), + tag_branch(to_branch_id), + tag_into_event(tag_branch(to_branch_id)), + tag_branch_merge_from(from_branch_id), + tag_into_event(tag_branch_merge_from(from_branch_id)), + tag_hashtag("ngit-event"), + tag_hashtag("ngit-format-0.0.1"), +]; + for t in hashtags.iter() { + tags.push( + nostr::Tag::Hashtag(t.to_string()) + ) + } + EventBuilder::new( + Kind::PullRequest.into_sdk_custom_kind(), + format!("PullRequest\n{title}\n\n{description}"), + &tags, + ) + .to_unsigned_event(keys.public_key()) + .sign(&keys) + .unwrap() +} -- cgit v1.2.3