examples/publish_pull_request.rs on Nostr: #[tokio::main] #[cfg(feature = "nostr")] async fn main() { use ...
#[tokio::main]
#[cfg(feature = "nostr")]
async fn main() {
use get_file_hash_core::publish_pull_request;
use nostr_sdk::Keys;
use nostr_sdk::EventId;
use std::str::FromStr;
let keys = Keys::generate();
let relay_urls = get_file_hash_core::get_relay_urls();
let d_tag = "my-awesome-repo-example";
let commit_id = "0123456789abcdef0123456789abcdef01234567";
let clone_url = "git@github.com:user/my-feature-branch.git";
let title = Some("Feat: Add new awesome feature example");
// Dummy EventId for examples that require a build_manifest_event_id
const DUMMY_BUILD_MANIFEST_ID_STR: &str = "f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0";
let dummy_build_manifest_id = EventId::from_str(DUMMY_BUILD_MANIFEST_ID_STR).unwrap();
// Example 1: Without title and build_manifest_event_id
println!("Publishing pull request without title and build_manifest_event_id...");
publish_pull_request!(
&keys,
&relay_urls,
d_tag,
commit_id,
clone_url
);
println!("Pull request without title and build_manifest_event_id published.");
// Example 2: With title but without build_manifest_event_id
println!("Publishing pull request with title but without build_manifest_event_id...");
publish_pull_request!(
&keys,
&relay_urls,
d_tag,
commit_id,
clone_url,
title
);
println!("Pull request with title but without build_manifest_event_id published.");
// Example 3: With build_manifest_event_id but without title
println!("Publishing pull request with build_manifest_event_id but without title...");
publish_pull_request!(
&keys,
&relay_urls,
d_tag,
commit_id,
clone_url,
None, // Explicitly pass None for title
Some(&dummy_build_manifest_id)
);
println!("Pull request with build_manifest_event_id but without title published.");
// Example 4: With title and build_manifest_event_id
println!("Publishing pull request with title and build_manifest_event_id...");
publish_pull_request!(
&keys,
&relay_urls,
d_tag,
commit_id,
clone_url,
title,
Some(&dummy_build_manifest_id)
);
println!("Pull request with title and build_manifest_event_id published.");
}
#[cfg(not(feature = "nostr"))]
fn main() {
println!("This example requires the 'nostr' feature. Please run with: cargo run --example publish_pull_request --features nostr");
}
Published at
2026-04-01 23:59:44 UTCEvent JSON
{
"id": "1e840dda1947a2166261d7a047f7b1c41cf168b7319afac58ef81301891e7cd6",
"pubkey": "25bb26c5843ae4e20d81f739c36fb9b3764c5348eac012dd3e27fae423eb39be",
"created_at": 1775087984,
"kind": 1,
"tags": [
[
"file",
"examples/publish_pull_request.rs"
],
[
"version",
"0.1.9"
]
],
"content": "#[tokio::main]\n#[cfg(feature = \"nostr\")]\nasync fn main() {\n use get_file_hash_core::publish_pull_request;\n use nostr_sdk::Keys;\n use nostr_sdk::EventId;\n use std::str::FromStr;\n\n let keys = Keys::generate();\n let relay_urls = get_file_hash_core::get_relay_urls();\n let d_tag = \"my-awesome-repo-example\";\n let commit_id = \"0123456789abcdef0123456789abcdef01234567\";\n let clone_url = \"git@github.com:user/my-feature-branch.git\";\n let title = Some(\"Feat: Add new awesome feature example\");\n\n // Dummy EventId for examples that require a build_manifest_event_id\n const DUMMY_BUILD_MANIFEST_ID_STR: \u0026str = \"f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0\";\n let dummy_build_manifest_id = EventId::from_str(DUMMY_BUILD_MANIFEST_ID_STR).unwrap();\n\n // Example 1: Without title and build_manifest_event_id\n println!(\"Publishing pull request without title and build_manifest_event_id...\");\n publish_pull_request!(\n \u0026keys,\n \u0026relay_urls,\n d_tag,\n commit_id,\n clone_url\n );\n println!(\"Pull request without title and build_manifest_event_id published.\");\n\n // Example 2: With title but without build_manifest_event_id\n println!(\"Publishing pull request with title but without build_manifest_event_id...\");\n publish_pull_request!(\n \u0026keys,\n \u0026relay_urls,\n d_tag,\n commit_id,\n clone_url,\n title\n );\n println!(\"Pull request with title but without build_manifest_event_id published.\");\n\n // Example 3: With build_manifest_event_id but without title\n println!(\"Publishing pull request with build_manifest_event_id but without title...\");\n publish_pull_request!(\n \u0026keys,\n \u0026relay_urls,\n d_tag,\n commit_id,\n clone_url,\n None, // Explicitly pass None for title\n Some(\u0026dummy_build_manifest_id)\n );\n println!(\"Pull request with build_manifest_event_id but without title published.\");\n\n // Example 4: With title and build_manifest_event_id\n println!(\"Publishing pull request with title and build_manifest_event_id...\");\n publish_pull_request!(\n \u0026keys,\n \u0026relay_urls,\n d_tag,\n commit_id,\n clone_url,\n title,\n Some(\u0026dummy_build_manifest_id)\n );\n println!(\"Pull request with title and build_manifest_event_id published.\");\n}\n\n#[cfg(not(feature = \"nostr\"))]\nfn main() {\n println!(\"This example requires the 'nostr' feature. Please run with: cargo run --example publish_pull_request --features nostr\");\n}\n",
"sig": "423a63d0a8c80f35072fdcf861d70116a242adf3912fec1fba1311a72f443d85945ee263b7c75bafd504793476a79d22252f0a8df05c13021b2b4e6ead16cb2d"
}