feat: add --personal-fork flag to repo announce command
Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
- New command `repo state` - by Awiteb
|
- New command `repo state` - by Awiteb
|
||||||
- Support pull requests - by Awiteb
|
- Support pull requests - by Awiteb
|
||||||
|
- Add `--personal-fork` flag to `repo announce` command - by Awiteb
|
||||||
|
|
||||||
### Breaking Change
|
### Breaking Change
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ Options:
|
|||||||
-c, --clone <CLONE> URLs for cloning the repository
|
-c, --clone <CLONE> URLs for cloning the repository
|
||||||
-m, --maintainers <MAINTAINERS> Additional maintainers of the repository (besides yourself)
|
-m, --maintainers <MAINTAINERS> Additional maintainers of the repository (besides yourself)
|
||||||
-l, --label <LABEL> Labels to categorize the repository. Can be specified multiple times
|
-l, --label <LABEL> Labels to categorize the repository. Can be specified multiple times
|
||||||
|
--personal-fork Indicates whether the announcement is a personal fork
|
||||||
--force-id Skip kebab-case validation for the repository ID
|
--force-id Skip kebab-case validation for the repository ID
|
||||||
--address-file If set, creates a `nostr-address` file to enable automatic address discovery by n34
|
--address-file If set, creates a `nostr-address` file to enable automatic address discovery by n34
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -18,7 +18,11 @@ use std::{fs, io::Write};
|
|||||||
|
|
||||||
use clap::Args;
|
use clap::Args;
|
||||||
use futures::future;
|
use futures::future;
|
||||||
use nostr::{event::EventBuilder, key::PublicKey, types::Url};
|
use nostr::{
|
||||||
|
event::{EventBuilder, Tag},
|
||||||
|
key::PublicKey,
|
||||||
|
types::Url,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
cli::{CliOptions, CommandRunner, NOSTR_ADDRESS_FILE, traits::RelayOrSetVecExt},
|
cli::{CliOptions, CommandRunner, NOSTR_ADDRESS_FILE, traits::RelayOrSetVecExt},
|
||||||
@@ -43,6 +47,7 @@ const NOSTR_ADDRESS_FILE_HEADER: &str = r##"# This file contains NIP-19 `naddr`
|
|||||||
# Empty lines are ignored. Lines starting with "#" are treated as comments.
|
# Empty lines are ignored. Lines starting with "#" are treated as comments.
|
||||||
|
|
||||||
"##;
|
"##;
|
||||||
|
const PERSONAL_FORK_HASHTAG: &str = "personal-fork";
|
||||||
|
|
||||||
/// Arguments for the `repo announce` command
|
/// Arguments for the `repo announce` command
|
||||||
#[derive(Args, Debug)]
|
#[derive(Args, Debug)]
|
||||||
@@ -71,6 +76,9 @@ pub struct AnnounceArgs {
|
|||||||
/// Skip kebab-case validation for the repository ID
|
/// Skip kebab-case validation for the repository ID
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
force_id: bool,
|
force_id: bool,
|
||||||
|
/// Indicates whether the announcement is a personal fork.
|
||||||
|
#[arg(long)]
|
||||||
|
personal_fork: bool,
|
||||||
/// If set, creates a `nostr-address` file to enable automatic address
|
/// If set, creates a `nostr-address` file to enable automatic address
|
||||||
/// discovery by n34
|
/// discovery by n34
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
@@ -94,7 +102,7 @@ impl CommandRunner for AnnounceArgs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let naddr = utils::repo_naddr(&self.repo_id, user_pubk, &relays)?;
|
let naddr = utils::repo_naddr(&self.repo_id, user_pubk, &relays)?;
|
||||||
let event = EventBuilder::new_git_repo(
|
let mut event_builder = EventBuilder::new_git_repo(
|
||||||
self.repo_id,
|
self.repo_id,
|
||||||
self.name.map(utils::str_trim),
|
self.name.map(utils::str_trim),
|
||||||
self.description.map(utils::str_trim),
|
self.description.map(utils::str_trim),
|
||||||
@@ -106,9 +114,13 @@ impl CommandRunner for AnnounceArgs {
|
|||||||
self.force_id,
|
self.force_id,
|
||||||
)?
|
)?
|
||||||
.dedup_tags()
|
.dedup_tags()
|
||||||
.pow(options.pow.unwrap_or_default())
|
.pow(options.pow.unwrap_or_default());
|
||||||
.build(user_pubk);
|
|
||||||
|
|
||||||
|
if self.personal_fork {
|
||||||
|
event_builder = event_builder.tag(Tag::hashtag(PERSONAL_FORK_HASHTAG));
|
||||||
|
}
|
||||||
|
|
||||||
|
let event = event_builder.build(user_pubk);
|
||||||
|
|
||||||
if self.address_file {
|
if self.address_file {
|
||||||
let address_path = std::env::current_dir()?.join(NOSTR_ADDRESS_FILE);
|
let address_path = std::env::current_dir()?.join(NOSTR_ADDRESS_FILE);
|
||||||
|
|||||||
Reference in New Issue
Block a user