diff options
Diffstat (limited to 'src/lib/repo_ref.rs')
| -rw-r--r-- | src/lib/repo_ref.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/lib/repo_ref.rs b/src/lib/repo_ref.rs index a9d1186..8705597 100644 --- a/src/lib/repo_ref.rs +++ b/src/lib/repo_ref.rs | |||
| @@ -38,6 +38,7 @@ pub struct RepoRef { | |||
| 38 | pub maintainers: Vec<PublicKey>, | 38 | pub maintainers: Vec<PublicKey>, |
| 39 | pub trusted_maintainer: PublicKey, | 39 | pub trusted_maintainer: PublicKey, |
| 40 | pub events: HashMap<Coordinate, nostr::Event>, | 40 | pub events: HashMap<Coordinate, nostr::Event>, |
| 41 | pub nostr_git_url: Option<NostrUrlDecoded>, | ||
| 41 | } | 42 | } |
| 42 | 43 | ||
| 43 | impl TryFrom<(nostr::Event, Option<PublicKey>)> for RepoRef { | 44 | impl TryFrom<(nostr::Event, Option<PublicKey>)> for RepoRef { |
| @@ -60,6 +61,7 @@ impl TryFrom<(nostr::Event, Option<PublicKey>)> for RepoRef { | |||
| 60 | maintainers: Vec::new(), | 61 | maintainers: Vec::new(), |
| 61 | trusted_maintainer: trusted_maintainer.unwrap_or(event.pubkey), | 62 | trusted_maintainer: trusted_maintainer.unwrap_or(event.pubkey), |
| 62 | events: HashMap::new(), | 63 | events: HashMap::new(), |
| 64 | nostr_git_url: None, | ||
| 63 | }; | 65 | }; |
| 64 | 66 | ||
| 65 | for tag in event.tags.iter() { | 67 | for tag in event.tags.iter() { |
| @@ -235,7 +237,14 @@ impl RepoRef { | |||
| 235 | .collect::<Vec<(Coordinate, Option<Timestamp>)>>() | 237 | .collect::<Vec<(Coordinate, Option<Timestamp>)>>() |
| 236 | } | 238 | } |
| 237 | 239 | ||
| 240 | pub fn set_nostr_git_url(&mut self, nostr_git_url: NostrUrlDecoded) { | ||
| 241 | self.nostr_git_url = Some(nostr_git_url) | ||
| 242 | } | ||
| 243 | |||
| 238 | pub fn to_nostr_git_url(&self, git_repo: &Option<&Repo>) -> String { | 244 | pub fn to_nostr_git_url(&self, git_repo: &Option<&Repo>) -> String { |
| 245 | if let Some(nostr_git_url) = &self.nostr_git_url { | ||
| 246 | return nostr_git_url.original_string.clone(); | ||
| 247 | } | ||
| 239 | let c = self.coordinate_with_hint(); | 248 | let c = self.coordinate_with_hint(); |
| 240 | format!("{}", NostrUrlDecoded { | 249 | format!("{}", NostrUrlDecoded { |
| 241 | original_string: String::new(), | 250 | original_string: String::new(), |
| @@ -550,6 +559,7 @@ mod tests { | |||
| 550 | trusted_maintainer: TEST_KEY_1_KEYS.public_key(), | 559 | trusted_maintainer: TEST_KEY_1_KEYS.public_key(), |
| 551 | maintainers: vec![TEST_KEY_1_KEYS.public_key(), TEST_KEY_2_KEYS.public_key()], | 560 | maintainers: vec![TEST_KEY_1_KEYS.public_key(), TEST_KEY_2_KEYS.public_key()], |
| 552 | events: HashMap::new(), | 561 | events: HashMap::new(), |
| 562 | nostr_git_url: None, | ||
| 553 | } | 563 | } |
| 554 | .to_event(&TEST_KEY_1_SIGNER) | 564 | .to_event(&TEST_KEY_1_SIGNER) |
| 555 | .await | 565 | .await |