refactor: Support more than one naddr instead of one

This commit supports multiple naddrs for sending issues to and searching
for repositories by extracting the embedded relays, and appending to the
address file instead of overwriting its previous contents. A header has
also been added to the `nostr-address` file to clarify its purpose.

This enhancement accommodates maintainers who distribute issue tracking
across multiple repositories, preventing confusion if the primary
maintainer steps down. Now, issues and patches will reference all
relevant repositories, not just one.

Note that repositories won't automatically include all maintainers'
addresses unless explicitly specified. Maintainers may manage a
repository under a project-specific public key rather than individual
keys. Addresses are only added to issues and patches when explicitly
provided via the command or written to the address file. This prevents
unintended inclusions and ensures clarity.

Suggested-by: DanConwayDev <DanConwayDev@protonmail.com>
Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
Awiteb
2025-05-27 06:42:05 +00:00
parent 87da5035da
commit 37cf601c01
8 changed files with 272 additions and 113 deletions

View File

@@ -220,21 +220,12 @@ pub fn nostr_address_path() -> std::io::Result<PathBuf> {
/// If the given coordinate is Some, return it. Otherwise, try to read and parse
/// the first non-comment line from the `nostr-address` file.
pub fn naddr_or_file(
naddr: Option<Nip19Coordinate>,
pub fn naddrs_or_file(
naddrs: Option<Vec<Nip19Coordinate>>,
address_file_path: &Path,
) -> N34Result<Nip19Coordinate> {
if let Some(naddr) = naddr {
return Ok(naddr);
) -> N34Result<Vec<Nip19Coordinate>> {
if let Some(naddrs) = naddrs {
return Ok(naddrs);
}
parsers::repo_naddr(
fs::read_to_string(address_file_path)
.map_err(N34Error::CanNotReadNostrAddressFile)?
.split("\n")
.find(|line| !line.starts_with("#") && !line.trim().is_empty())
.ok_or(N34Error::EmptyNostrAddressFile)?
.trim(),
)
.map_err(N34Error::InvalidNostrAddressFileContent)
parsers::parse_nostr_address_file(address_file_path)
}