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/bin/ngit/sub_commands/sync.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/bin/ngit/sub_commands/sync.rs b/src/bin/ngit/sub_commands/sync.rs
index b377ab4..99cd2d8 100644
--- a/src/bin/ngit/sub_commands/sync.rs
+++ b/src/bin/ngit/sub_commands/sync.rs
@@ -130,6 +130,12 @@ pub async fn launch(args: &SubCommandArgs) -> Result<()> {
130 if missing_refs.contains(nostr_ref_name) { 130 if missing_refs.contains(nostr_ref_name) {
131 continue; 131 continue;
132 } 132 }
133 // strip refs/heads/ or refs/tags/ prefix to get the tracking ref segment
134 // e.g. refs/heads/master -> master, refs/tags/v1.0.0 -> v1.0.0
135 let tracking_ref_name = nostr_ref_name
136 .strip_prefix("refs/heads/")
137 .or_else(|| nostr_ref_name.strip_prefix("refs/tags/"))
138 .unwrap_or(nostr_ref_name.as_str());
133 if invalid_nostr_state_ref(nostr_ref_name) { 139 if invalid_nostr_state_ref(nostr_ref_name) {
134 // ensure nostr_state only supports refs/heads and refs/tags/ 140 // ensure nostr_state only supports refs/heads and refs/tags/
135 // and not refs/heads/prs/* 141 // and not refs/heads/prs/*
@@ -155,11 +161,11 @@ pub async fn launch(args: &SubCommandArgs) -> Result<()> {
155 // dont try and sync push symbolic refs 161 // dont try and sync push symbolic refs
156 } else if !force_required { 162 } else if !force_required {
157 refspecs.push(format!( 163 refspecs.push(format!(
158 "refs/remotes/{nostr_remote_name}/{nostr_ref_name}:{nostr_ref_name}", 164 "refs/remotes/{nostr_remote_name}/{tracking_ref_name}:{nostr_ref_name}",
159 )); 165 ));
160 } else if *is_grasp_server || args.force { 166 } else if *is_grasp_server || args.force {
161 refspecs.push(format!( 167 refspecs.push(format!(
162 "+refs/remotes/{nostr_remote_name}/{nostr_ref_name}:{nostr_ref_name}", 168 "+refs/remotes/{nostr_remote_name}/{tracking_ref_name}:{nostr_ref_name}",
163 )); 169 ));
164 } else { 170 } else {
165 not_updated.push(nostr_ref_name); 171 not_updated.push(nostr_ref_name);
@@ -167,7 +173,7 @@ pub async fn launch(args: &SubCommandArgs) -> Result<()> {
167 } else { 173 } else {
168 // add missing refs 174 // add missing refs
169 refspecs.push(format!( 175 refspecs.push(format!(
170 "refs/remotes/{nostr_remote_name}/{nostr_ref_name}:{nostr_ref_name}", 176 "refs/remotes/{nostr_remote_name}/{tracking_ref_name}:{nostr_ref_name}",
171 )); 177 ));
172 } 178 }
173 } 179 }