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/git/handlers.rs40
-rw-r--r--src/http/mod.rs2
2 files changed, 33 insertions, 9 deletions
diff --git a/src/git/handlers.rs b/src/git/handlers.rs
index 7244abb..28cb47f 100644
--- a/src/git/handlers.rs
+++ b/src/git/handlers.rs
@@ -156,7 +156,10 @@ pub async fn handle_upload_pack(
156 stdin 156 stdin
157 .write_all(&request_body) 157 .write_all(&request_body)
158 .await 158 .await
159 .map_err(GitError::IoError)?; 159 .map_err(|e| {
160 error!("Failed to write to git upload-pack stdin: {}", e);
161 GitError::IoError(e)
162 })?;
160 // Close stdin to signal end of input 163 // Close stdin to signal end of input
161 drop(stdin); 164 drop(stdin);
162 } 165 }
@@ -170,7 +173,10 @@ pub async fn handle_upload_pack(
170 stdout 173 stdout
171 .read_to_end(&mut output) 174 .read_to_end(&mut output)
172 .await 175 .await
173 .map_err(GitError::IoError)?; 176 .map_err(|e| {
177 error!("Failed to read git upload-pack stdout: {}", e);
178 GitError::IoError(e)
179 })?;
174 } 180 }
175 181
176 if let Some(stderr) = git.take_stderr() { 182 if let Some(stderr) = git.take_stderr() {
@@ -178,11 +184,17 @@ pub async fn handle_upload_pack(
178 stderr 184 stderr
179 .read_to_end(&mut stderr_output) 185 .read_to_end(&mut stderr_output)
180 .await 186 .await
181 .map_err(GitError::IoError)?; 187 .map_err(|e| {
188 error!("Failed to read git upload-pack stderr: {}", e);
189 GitError::IoError(e)
190 })?;
182 } 191 }
183 192
184 // Wait for process 193 // Wait for process
185 let status = git.wait().await.map_err(GitError::IoError)?; 194 let status = git.wait().await.map_err(|e| {
195 error!("Failed to wait for git upload-pack process: {}", e);
196 GitError::IoError(e)
197 })?;
186 198
187 if !status.success() { 199 if !status.success() {
188 let stderr_str = String::from_utf8_lossy(&stderr_output); 200 let stderr_str = String::from_utf8_lossy(&stderr_output);
@@ -299,7 +311,10 @@ pub async fn handle_receive_pack(
299 stdin 311 stdin
300 .write_all(&request_body) 312 .write_all(&request_body)
301 .await 313 .await
302 .map_err(GitError::IoError)?; 314 .map_err(|e| {
315 error!("Failed to write to git receive-pack stdin: {}", e);
316 GitError::IoError(e)
317 })?;
303 drop(stdin); 318 drop(stdin);
304 } 319 }
305 320
@@ -312,7 +327,10 @@ pub async fn handle_receive_pack(
312 stdout 327 stdout
313 .read_to_end(&mut output) 328 .read_to_end(&mut output)
314 .await 329 .await
315 .map_err(GitError::IoError)?; 330 .map_err(|e| {
331 error!("Failed to read git receive-pack stdout: {}", e);
332 GitError::IoError(e)
333 })?;
316 } 334 }
317 335
318 if let Some(stderr) = git.take_stderr() { 336 if let Some(stderr) = git.take_stderr() {
@@ -320,11 +338,17 @@ pub async fn handle_receive_pack(
320 stderr 338 stderr
321 .read_to_end(&mut stderr_output) 339 .read_to_end(&mut stderr_output)
322 .await 340 .await
323 .map_err(GitError::IoError)?; 341 .map_err(|e| {
342 error!("Failed to read git receive-pack stderr: {}", e);
343 GitError::IoError(e)
344 })?;
324 } 345 }
325 346
326 // Wait for process 347 // Wait for process
327 let status = git.wait().await.map_err(GitError::IoError)?; 348 let status = git.wait().await.map_err(|e| {
349 error!("Failed to wait for git receive-pack process: {}", e);
350 GitError::IoError(e)
351 })?;
328 352
329 if !status.success() { 353 if !status.success() {
330 let stderr_str = String::from_utf8_lossy(&stderr_output); 354 let stderr_str = String::from_utf8_lossy(&stderr_output);
diff --git a/src/http/mod.rs b/src/http/mod.rs
index ffb1562..edc28a3 100644
--- a/src/http/mod.rs
+++ b/src/http/mod.rs
@@ -332,7 +332,7 @@ impl Service<Request<Incoming>> for HttpService {
332 .unwrap()) 332 .unwrap())
333 } 333 }
334 Err(e) => { 334 Err(e) => {
335 tracing::error!("Git handler error: {}", e); 335 // Errors are already logged at their source with full context
336 let error_msg = format!("Git error: {}", e); 336 let error_msg = format!("Git error: {}", e);
337 Ok(add_cors_headers(Response::builder()) 337 Ok(add_cors_headers(Response::builder())
338 .status(e.status_code()) 338 .status(e.status_code())