upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/git_remote_helper.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-08-01 15:58:43 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2024-08-01 15:58:43 +0100
commitc58ff090c50f642c7aaf48191aeb6aea4cd06a72 (patch)
tree117ec3e250e1a04cf2e9d7efacd365547de44241 /src/git_remote_helper.rs
parent6b63f150ba9e7c69bf83bcbd24543051c765c9f6 (diff)
Revert "fix(remote): display nostr fetch report"
This reverts commit 6b63f150ba9e7c69bf83bcbd24543051c765c9f6.
Diffstat (limited to 'src/git_remote_helper.rs')
-rw-r--r--src/git_remote_helper.rs33
1 files changed, 5 insertions, 28 deletions
diff --git a/src/git_remote_helper.rs b/src/git_remote_helper.rs
index 1c1688d..6dc00cb 100644
--- a/src/git_remote_helper.rs
+++ b/src/git_remote_helper.rs
@@ -9,14 +9,15 @@ use std::{
9 collections::{HashMap, HashSet}, 9 collections::{HashMap, HashSet},
10 env, 10 env,
11 io::{self, Stdin}, 11 io::{self, Stdin},
12 path::{Path, PathBuf}, 12 path::PathBuf,
13}; 13};
14 14
15use anyhow::{bail, Context, Result}; 15use anyhow::{bail, Context, Result};
16use auth_git2::GitAuthenticator; 16use auth_git2::GitAuthenticator;
17#[cfg(not(test))]
18use client::Connect;
17use client::{ 19use client::{
18 consolidate_fetch_reports, get_repo_ref_from_cache, get_state_from_cache, sign_event, Connect, 20 fetching_with_report, get_repo_ref_from_cache, get_state_from_cache, sign_event, STATE_KIND,
19 STATE_KIND,
20}; 21};
21use git::RepoActions; 22use git::RepoActions;
22use git2::{Oid, Repository}; 23use git2::{Oid, Repository};
@@ -71,7 +72,7 @@ async fn main() -> Result<()> {
71 let repo_coordinates = 72 let repo_coordinates =
72 nostr_git_url_to_repo_coordinates(nostr_remote_url).context("invalid nostr url")?; 73 nostr_git_url_to_repo_coordinates(nostr_remote_url).context("invalid nostr url")?;
73 74
74 fetching_with_report_for_helper(git_repo_path, &client, &repo_coordinates).await?; 75 fetching_with_report(git_repo_path, &client, &repo_coordinates).await?;
75 76
76 let repo_ref = get_repo_ref_from_cache(git_repo_path, &repo_coordinates).await?; 77 let repo_ref = get_repo_ref_from_cache(git_repo_path, &repo_coordinates).await?;
77 78
@@ -189,30 +190,6 @@ fn nostr_git_url_to_repo_coordinates(url: &str) -> Result<HashSet<Coordinate>> {
189 ); 190 );
190} 191}
191 192
192async fn fetching_with_report_for_helper(
193 git_repo_path: &Path,
194 #[cfg(test)] client: &crate::client::MockConnect,
195 #[cfg(not(test))] client: &Client,
196 repo_coordinates: &HashSet<Coordinate>,
197) -> Result<()> {
198 let term = console::Term::stderr();
199 term.write_line("fetching from nostr...")?;
200 let (relay_reports, progress_reporter) = client
201 .fetch_all(git_repo_path, repo_coordinates, &HashSet::new())
202 .await?;
203 if !relay_reports.iter().any(std::result::Result::is_err) {
204 let _ = progress_reporter.clear();
205 term.clear_last_lines(1)?;
206 }
207 let report = consolidate_fetch_reports(relay_reports);
208 if report.to_string().is_empty() {
209 term.write_line("no updates on nostr")?;
210 } else {
211 term.write_line(&format!("nostr updates: {report}"))?;
212 }
213 Ok(())
214}
215
216async fn list(git_repo: &Repo, repo_ref: &RepoRef, for_push: bool) -> Result<()> { 193async fn list(git_repo: &Repo, repo_ref: &RepoRef, for_push: bool) -> Result<()> {
217 if let Ok(repo_state) = get_state_from_cache(git_repo.get_path()?, repo_ref).await { 194 if let Ok(repo_state) = get_state_from_cache(git_repo.get_path()?, repo_ref).await {
218 for (name, value) in &repo_state.state { 195 for (name, value) in &repo_state.state {