diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-11-26 07:48:30 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-11-26 12:26:47 +0000 |
| commit | a0593e3aa9b19b9ca3c3881cbe0d9d207fe46d2c (patch) | |
| tree | 3482e7c558eff09cc91604ad6ddcd02cf2c94699 /src/bin/git_remote_nostr/push.rs | |
| parent | 1332c625b75fce616e06b415c99a068bc45c8210 (diff) | |
refactor: err msgs 'cannot' > 'failed to'
in nearly all cases 'cannot' was used when an action was tried and
failed. 'failed to' is strictly better because:
* just because the action didn't work that time doesnt mean it
cannot work
* it is better at drawing the users attention to a problem
Diffstat (limited to 'src/bin/git_remote_nostr/push.rs')
| -rw-r--r-- | src/bin/git_remote_nostr/push.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs index 7161c5d..381a45e 100644 --- a/src/bin/git_remote_nostr/push.rs +++ b/src/bin/git_remote_nostr/push.rs | |||
| @@ -92,7 +92,7 @@ pub async fn run_push( | |||
| 92 | list_outputs.get(url).unwrap().to_owned() | 92 | list_outputs.get(url).unwrap().to_owned() |
| 93 | } else { | 93 | } else { |
| 94 | bail!( | 94 | bail!( |
| 95 | "cannot connect to git servers: {}", | 95 | "failed to connect to git servers: {}", |
| 96 | repo_ref.git_server.join(" ") | 96 | repo_ref.git_server.join(" ") |
| 97 | ); | 97 | ); |
| 98 | } | 98 | } |
| @@ -245,7 +245,7 @@ pub async fn run_push( | |||
| 245 | &[], | 245 | &[], |
| 246 | ) | 246 | ) |
| 247 | .await | 247 | .await |
| 248 | .context("cannot make patch event from commit")?; | 248 | .context("failed to make patch event from commit")?; |
| 249 | events.push(new_patch.clone()); | 249 | events.push(new_patch.clone()); |
| 250 | parent_patch = new_patch; | 250 | parent_patch = new_patch; |
| 251 | } | 251 | } |
| @@ -259,7 +259,7 @@ pub async fn run_push( | |||
| 259 | ) | 259 | ) |
| 260 | .unwrap(); | 260 | .unwrap(); |
| 261 | println!( | 261 | println!( |
| 262 | "error {to} cannot fastforward as newer patches found on proposal" | 262 | "error {to} failed to fastforward as newer patches found on proposal" |
| 263 | ); | 263 | ); |
| 264 | rejected_proposal_refspecs.push(refspec.to_string()); | 264 | rejected_proposal_refspecs.push(refspec.to_string()); |
| 265 | } | 265 | } |
| @@ -1089,7 +1089,7 @@ fn update_remote_refs_pushed( | |||
| 1089 | } | 1089 | } |
| 1090 | } else { | 1090 | } else { |
| 1091 | let commit = reference_to_commit(git_repo, from) | 1091 | let commit = reference_to_commit(git_repo, from) |
| 1092 | .context(format!("cannot get commit of reference {from}"))?; | 1092 | .context(format!("failed to get commit of reference {from}"))?; |
| 1093 | if let Ok(mut remote_ref) = git_repo.find_reference(&target_ref_name) { | 1093 | if let Ok(mut remote_ref) = git_repo.find_reference(&target_ref_name) { |
| 1094 | remote_ref.set_target(commit, "updated by nostr remote helper")?; | 1094 | remote_ref.set_target(commit, "updated by nostr remote helper")?; |
| 1095 | } else { | 1095 | } else { |
| @@ -1142,9 +1142,9 @@ fn refspec_remote_ref_name( | |||
| 1142 | fn reference_to_commit(git_repo: &Repository, reference: &str) -> Result<Oid> { | 1142 | fn reference_to_commit(git_repo: &Repository, reference: &str) -> Result<Oid> { |
| 1143 | Ok(git_repo | 1143 | Ok(git_repo |
| 1144 | .find_reference(reference) | 1144 | .find_reference(reference) |
| 1145 | .context(format!("cannot find reference: {reference}"))? | 1145 | .context(format!("failed to find reference: {reference}"))? |
| 1146 | .peel_to_commit() | 1146 | .peel_to_commit() |
| 1147 | .context(format!("cannot get commit from reference: {reference}"))? | 1147 | .context(format!("failed to get commit from reference: {reference}"))? |
| 1148 | .id()) | 1148 | .id()) |
| 1149 | } | 1149 | } |
| 1150 | 1150 | ||
| @@ -1152,13 +1152,13 @@ fn reference_to_commit(git_repo: &Repository, reference: &str) -> Result<Oid> { | |||
| 1152 | fn reference_to_ref_value(git_repo: &Repository, reference: &str) -> Result<String> { | 1152 | fn reference_to_ref_value(git_repo: &Repository, reference: &str) -> Result<String> { |
| 1153 | let reference_obj = git_repo | 1153 | let reference_obj = git_repo |
| 1154 | .find_reference(reference) | 1154 | .find_reference(reference) |
| 1155 | .context(format!("cannot find reference: {reference}"))?; | 1155 | .context(format!("failed to find reference: {reference}"))?; |
| 1156 | if let Some(symref) = reference_obj.symbolic_target() { | 1156 | if let Some(symref) = reference_obj.symbolic_target() { |
| 1157 | Ok(symref.to_string()) | 1157 | Ok(symref.to_string()) |
| 1158 | } else { | 1158 | } else { |
| 1159 | Ok(reference_obj | 1159 | Ok(reference_obj |
| 1160 | .peel_to_commit() | 1160 | .peel_to_commit() |
| 1161 | .context(format!("cannot get commit from reference: {reference}"))? | 1161 | .context(format!("failed to get commit from reference: {reference}"))? |
| 1162 | .id() | 1162 | .id() |
| 1163 | .to_string()) | 1163 | .to_string()) |
| 1164 | } | 1164 | } |