upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/bin/git_remote_nostr
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-11-26 07:48:30 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2024-11-26 12:26:47 +0000
commita0593e3aa9b19b9ca3c3881cbe0d9d207fe46d2c (patch)
tree3482e7c558eff09cc91604ad6ddcd02cf2c94699 /src/bin/git_remote_nostr
parent1332c625b75fce616e06b415c99a068bc45c8210 (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')
-rw-r--r--src/bin/git_remote_nostr/fetch.rs4
-rw-r--r--src/bin/git_remote_nostr/list.rs2
-rw-r--r--src/bin/git_remote_nostr/push.rs16
3 files changed, 11 insertions, 11 deletions
diff --git a/src/bin/git_remote_nostr/fetch.rs b/src/bin/git_remote_nostr/fetch.rs
index a972a2f..90387f3 100644
--- a/src/bin/git_remote_nostr/fetch.rs
+++ b/src/bin/git_remote_nostr/fetch.rs
@@ -110,7 +110,7 @@ pub fn make_commits_for_proposal(
110 let commit_id = git_repo 110 let commit_id = git_repo
111 .create_commit_from_patch(patch, Some(tip_commit_id.clone())) 111 .create_commit_from_patch(patch, Some(tip_commit_id.clone()))
112 .context(format!( 112 .context(format!(
113 "cannot create commit for patch {}", 113 "failed to create commit for patch {}",
114 nip19::Nip19Event { 114 nip19::Nip19Event {
115 event_id: patch.id, 115 event_id: patch.id,
116 author: Some(patch.pubkey), 116 author: Some(patch.pubkey),
@@ -146,7 +146,7 @@ async fn fetch_proposals(
146 { 146 {
147 if let Err(error) = make_commits_for_proposal(git_repo, repo_ref, patches) { 147 if let Err(error) = make_commits_for_proposal(git_repo, repo_ref, patches) {
148 term.write_line( 148 term.write_line(
149 format!("WARNING: cannot create branch for {refstr}, error: {error}",) 149 format!("WARNING: failed to create branch for {refstr}, error: {error}",)
150 .as_str(), 150 .as_str(),
151 )?; 151 )?;
152 break; 152 break;
diff --git a/src/bin/git_remote_nostr/list.rs b/src/bin/git_remote_nostr/list.rs
index daff1b6..9171544 100644
--- a/src/bin/git_remote_nostr/list.rs
+++ b/src/bin/git_remote_nostr/list.rs
@@ -163,7 +163,7 @@ async fn get_open_proposals_state(
163 } 163 }
164 Err(error) => { 164 Err(error) => {
165 let _ = term.write_line( 165 let _ = term.write_line(
166 format!("WARNING: cannot fetch branch {branch_name} error: {error}") 166 format!("WARNING: failed to fetch branch {branch_name} error: {error}")
167 .as_str(), 167 .as_str(),
168 ); 168 );
169 } 169 }
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(
1142fn reference_to_commit(git_repo: &Repository, reference: &str) -> Result<Oid> { 1142fn 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> {
1152fn reference_to_ref_value(git_repo: &Repository, reference: &str) -> Result<String> { 1152fn 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 }