diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-08-07 10:21:28 +0100 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-08-07 17:40:33 +0100 |
| commit | 646d05e44946c5a248cb8c5b7d852ed316b9592e (patch) | |
| tree | 41c57086c0fec1bdadc558b5248cc1f9b346eaa8 /src/bin/ngit | |
| parent | b27cee69f89a08cc8e97de705212440239e6049b (diff) | |
fix(send): push PR refs to non-grasp servers
attempt to use a range of protocols instead of unath http
Diffstat (limited to 'src/bin/ngit')
| -rw-r--r-- | src/bin/ngit/sub_commands/sync.rs | 66 |
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..e7033b2 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 ¬_deleted { | 134 | &decoded_nostr_url, |
| 150 | term.write_line(&format!(" - {name} not deleted"))?; | 135 | &refspecs, |
| 151 | } | 136 | &term, |
| 152 | for name in ¬_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(failed_refs) => { | ||
| 145 | if failed_refs.is_empty() { | ||
| 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 ¬_deleted { | ||
| 161 | term.write_line(&format!(" - {name} not deleted"))?; | ||
| 162 | } | ||
| 163 | for name in ¬_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 | ||