npub1xu…g43rm 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-04 01:45:22 UTCEvent JSON
{
"id": "51b64d5262d0d899408f4679de63095d61c14d5a7a9c31c2b9b69663b5cea32e",
"pubkey": "37306250e62aafbe17f1fd1ee25a539f268e044d7516734c6e389c6de7273ac9",
"created_at": 1775267122,
"kind": 1,
"tags": [
[
"file",
"examples/publish_pull_request.rs"
],
[
"version",
"0.3.3"
]
],
"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": "108ae81366d14c8d8c8a1205855f8b5c4191f692f7507e942afb969301cded21779209f4ead74b4a3511a07e43aa69e6849ae5c752f2e3a0bb51021d77256cab"
}