upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/git_remote_helper.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/git_remote_helper.rs b/src/git_remote_helper.rs
index 38a0aa5..de49275 100644
--- a/src/git_remote_helper.rs
+++ b/src/git_remote_helper.rs
@@ -93,8 +93,8 @@ async fn main() -> Result<()> {
93 ["option", ..] => { 93 ["option", ..] => {
94 println!("unsupported"); 94 println!("unsupported");
95 } 95 }
96 ["fetch", _oid, refstr] => { 96 ["fetch", oid, _refstr] => {
97 fetch(&git_repo.git_repo, &repo_ref, &stdin, refstr)?; 97 fetch(&git_repo.git_repo, &repo_ref, &stdin, oid)?;
98 } 98 }
99 ["push", refspec] => { 99 ["push", refspec] => {
100 push( 100 push(
@@ -182,14 +182,14 @@ async fn list(git_repo: &Repo, repo_ref: &RepoRef, for_push: bool) -> Result<()>
182 Ok(()) 182 Ok(())
183} 183}
184 184
185fn fetch(git_repo: &Repository, repo_ref: &RepoRef, stdin: &Stdin, refstr: &str) -> Result<()> { 185fn fetch(git_repo: &Repository, repo_ref: &RepoRef, stdin: &Stdin, oid: &str) -> Result<()> {
186 let git_server_remote_url = repo_ref 186 let git_server_remote_url = repo_ref
187 .git_server 187 .git_server
188 .first() 188 .first()
189 .context("no git server listed in nostr repository announcement")?; 189 .context("no git server listed in nostr repository announcement")?;
190 let mut git_server_remote = git_repo.remote_anonymous(git_server_remote_url)?; 190 let mut git_server_remote = git_repo.remote_anonymous(git_server_remote_url)?;
191 git_server_remote.connect(git2::Direction::Fetch)?; 191 git_server_remote.connect(git2::Direction::Fetch)?;
192 git_server_remote.download(&get_refstrs_from_fetch_batch(stdin, refstr)?, None)?; 192 git_server_remote.download(&get_oids_from_fetch_batch(stdin, oid)?, None)?;
193 git_server_remote.disconnect()?; 193 git_server_remote.disconnect()?;
194 println!(); 194 println!();
195 Ok(()) 195 Ok(())
@@ -422,14 +422,14 @@ fn get_remote_name_by_url(git_repo: &Repository, url: &str) -> Result<String> {
422 .to_string()) 422 .to_string())
423} 423}
424 424
425fn get_refstrs_from_fetch_batch(stdin: &Stdin, initial_refstr: &str) -> Result<Vec<String>> { 425fn get_oids_from_fetch_batch(stdin: &Stdin, initial_oid: &str) -> Result<Vec<String>> {
426 let mut line = String::new(); 426 let mut line = String::new();
427 let mut refstrs = vec![initial_refstr.to_string()]; 427 let mut oids = vec![initial_oid.to_string()];
428 loop { 428 loop {
429 let tokens = read_line(stdin, &mut line)?; 429 let tokens = read_line(stdin, &mut line)?;
430 match tokens.as_slice() { 430 match tokens.as_slice() {
431 ["fetch", _oid, refstr] => { 431 ["fetch", oid, _refstr] => {
432 refstrs.push((*refstr).to_string()); 432 oids.push((*oid).to_string());
433 } 433 }
434 [] => break, 434 [] => break,
435 _ => bail!( 435 _ => bail!(
@@ -437,7 +437,7 @@ fn get_refstrs_from_fetch_batch(stdin: &Stdin, initial_refstr: &str) -> Result<V
437 ), 437 ),
438 } 438 }
439 } 439 }
440 Ok(refstrs) 440 Ok(oids)
441} 441}
442 442
443fn get_refspecs_from_push_batch(stdin: &Stdin, initial_refspec: &str) -> Result<Vec<String>> { 443fn get_refspecs_from_push_batch(stdin: &Stdin, initial_refspec: &str) -> Result<Vec<String>> {