upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-06-19 09:30:16 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2025-06-19 09:30:16 +0100
commit9386cc2e409cc4117ae1792411179a9cd986b3f3 (patch)
tree79d7c002f24eae80bf9d274e081ea1f7435e27e7 /src/bin
parent20f2680394e0b62864b1b192338b3cd7ecdad4ec (diff)
refactor: move build state function
in preparation for enforcing the inclusion of HEAD
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/git_remote_nostr/push.rs37
1 files changed, 1 insertions, 36 deletions
diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs
index 56bf177..434dae9 100644
--- a/src/bin/git_remote_nostr/push.rs
+++ b/src/bin/git_remote_nostr/push.rs
@@ -8,9 +8,7 @@ use std::{
8 8
9use anyhow::{Context, Result, anyhow, bail}; 9use anyhow::{Context, Result, anyhow, bail};
10use auth_git2::GitAuthenticator; 10use auth_git2::GitAuthenticator;
11use client::{ 11use client::{get_events_from_local_cache, get_state_from_cache, send_events, sign_event};
12 STATE_KIND, get_events_from_local_cache, get_state_from_cache, send_events, sign_event,
13};
14use console::Term; 12use console::Term;
15use git::{RepoActions, sha1_to_oid}; 13use git::{RepoActions, sha1_to_oid};
16use git_events::{ 14use git_events::{
@@ -1549,39 +1547,6 @@ fn get_refspecs_from_push_batch(stdin: &Stdin, initial_refspec: &str) -> Result<
1549 Ok(refspecs) 1547 Ok(refspecs)
1550} 1548}
1551 1549
1552trait BuildRepoState {
1553 async fn build(
1554 identifier: String,
1555 state: HashMap<String, String>,
1556 signer: &Arc<dyn NostrSigner>,
1557 ) -> Result<RepoState>;
1558}
1559impl BuildRepoState for RepoState {
1560 async fn build(
1561 identifier: String,
1562 state: HashMap<String, String>,
1563 signer: &Arc<dyn NostrSigner>,
1564 ) -> Result<RepoState> {
1565 let mut tags = vec![Tag::identifier(identifier.clone())];
1566 for (name, value) in &state {
1567 tags.push(Tag::custom(nostr_sdk::TagKind::Custom(name.into()), vec![
1568 value.clone(),
1569 ]));
1570 }
1571 let event = sign_event(
1572 EventBuilder::new(STATE_KIND, "").tags(tags),
1573 signer,
1574 "git state".to_string(),
1575 )
1576 .await?;
1577 Ok(RepoState {
1578 identifier,
1579 state,
1580 event,
1581 })
1582 }
1583}
1584
1585#[cfg(test)] 1550#[cfg(test)]
1586mod tests { 1551mod tests {
1587 use super::*; 1552 use super::*;