upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/bin/ngit/sub_commands/sync.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-08-07 17:52:22 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2025-08-07 17:52:22 +0100
commit92c2362a9bed1bc1f256e7948e087c4102b7c4f9 (patch)
tree700bf840ba52a8bd576afcfbe532a669f104dfcb /src/bin/ngit/sub_commands/sync.rs
parent8724af191f520a822214109f75a1851856c74fd2 (diff)
parentfa7adf840ac2d78defee398a61b60888f615622a (diff)
Merge branch 'add-prs-to-ngit-send'
Diffstat (limited to 'src/bin/ngit/sub_commands/sync.rs')
-rw-r--r--src/bin/ngit/sub_commands/sync.rs66
1 files changed, 40 insertions, 26 deletions
diff --git a/src/bin/ngit/sub_commands/sync.rs b/src/bin/ngit/sub_commands/sync.rs
index c1a3484..00dfe75 100644
--- a/src/bin/ngit/sub_commands/sync.rs
+++ b/src/bin/ngit/sub_commands/sync.rs
@@ -127,33 +127,47 @@ pub async fn launch(args: &SubCommandArgs) -> Result<()> {
127 term.write_line(&format!("{remote_name} already in sync"))?; 127 term.write_line(&format!("{remote_name} already in sync"))?;
128 } 128 }
129 // report already in sync 129 // report already in sync
130 } else if let Err(error) = push_to_remote(
131 &git_repo,
132 url,
133 &decoded_nostr_url,
134 &refspecs,
135 &term,
136 *is_grasp_server,
137 ) {
138 term.write_line(&format!(
139 "error pushing updates to {remote_name}: error: {error}"
140 ))?;
141 } else if *is_grasp_server || args.force {
142 term.write_line(&format!("{remote_name} sync completed"))?;
143 // TODO we only know if there was an error but not if it
144 // rejected any updates
145 } else { 130 } else {
146 // we should report on refs not force pushed 131 match push_to_remote(
147 term.write_line(&format!("{remote_name} sync completed"))?; 132 &git_repo,
148 } 133 url,
149 for name in &not_deleted { 134 &decoded_nostr_url,
150 term.write_line(&format!(" - {name} not deleted"))?; 135 &refspecs,
151 } 136 &term,
152 for name in &not_updated { 137 *is_grasp_server,
153 term.write_line(&format!(" - {name} not updated due to conflicts"))?; 138 ) {
154 } 139 Err(error) => {
155 if !not_updated.is_empty() || !not_deleted.is_empty() { 140 term.write_line(&format!(
156 term.write_line("run `ngit sync --force` to delete refs or overwrite conflicts and potentially lose work")?; 141 "error pushing updates to {remote_name}: error: {error}"
142 ))?;
143 }
144 Ok(updated_refs) => {
145 if updated_refs.values().all(std::option::Option::is_none) {
146 if *is_grasp_server || args.force {
147 term.write_line(&format!("{remote_name} sync completed"))?;
148 // TODO we only know if there was an error but not
149 // if it rejected any
150 // updates
151 } else {
152 // we should report on refs not force pushed
153 term.write_line(&format!("{remote_name} sync completed"))?;
154 }
155 } else {
156 term.write_line(&format!(
157 "{remote_name} sync completed but not all changes were accepted"
158 ))?;
159 }
160 for name in &not_deleted {
161 term.write_line(&format!(" - {name} not deleted"))?;
162 }
163 for name in &not_updated {
164 term.write_line(&format!(" - {name} not updated due to conflicts"))?;
165 }
166 if !not_updated.is_empty() || !not_deleted.is_empty() {
167 term.write_line("run `ngit sync --force` to delete refs or overwrite conflicts and potentially lose work")?;
168 }
169 }
170 }
157 } 171 }
158 } 172 }
159 173