@@ -178,6 +178,7 @@ func fetchRepo(ctx context.Context, url string, forceUpdate bool) error {
178178 if os .IsNotExist (err ) {
179179 deleteLastFetch (url )
180180 }
181+
181182 return fmt .Errorf ("failed to read file: %w" , err )
182183 }
183184
@@ -340,9 +341,11 @@ func gitHandler(w http.ResponseWriter, r *http.Request) {
340341 logger .Error ("Error fetching blob" , slog .String ("url" , url ), slog .Any ("error" , err ))
341342 if isAuthError (err ) {
342343 http .Error (w , fmt .Sprintf ("Error fetching blob: %v" , err ), http .StatusForbidden )
344+
343345 return
344346 }
345347 http .Error (w , fmt .Sprintf ("Error fetching blob: %v" , err ), http .StatusInternalServerError )
348+
346349 return
347350 }
348351
@@ -354,6 +357,7 @@ func gitHandler(w http.ResponseWriter, r *http.Request) {
354357 if err != nil {
355358 logger .Error ("Error archiving blob" , slog .String ("url" , url ), slog .Any ("error" , err ))
356359 http .Error (w , fmt .Sprintf ("Error archiving blob: %v" , err ), http .StatusInternalServerError )
360+
357361 return
358362 }
359363 fileData := fileDataAny .([]byte )
@@ -381,6 +385,7 @@ func cacheHandler(w http.ResponseWriter, r *http.Request) {
381385 err := json .NewDecoder (r .Body ).Decode (& body )
382386 if err != nil {
383387 http .Error (w , fmt .Sprintf ("Error decoding JSON: %v" , err ), http .StatusBadRequest )
388+
384389 return
385390 }
386391 defer r .Body .Close ()
@@ -396,9 +401,11 @@ func cacheHandler(w http.ResponseWriter, r *http.Request) {
396401 logger .Error ("Error fetching blob" , slog .String ("url" , url ), slog .Any ("error" , err ))
397402 if isAuthError (err ) {
398403 http .Error (w , fmt .Sprintf ("Error fetching blob: %v" , err ), http .StatusForbidden )
404+
399405 return
400406 }
401407 http .Error (w , fmt .Sprintf ("Error fetching blob: %v" , err ), http .StatusInternalServerError )
408+
402409 return
403410 }
404411
@@ -412,6 +419,7 @@ func cacheHandler(w http.ResponseWriter, r *http.Request) {
412419 if err != nil {
413420 logger .Error ("Failed to load repository" , slog .String ("url" , url ), slog .Any ("error" , err ))
414421 http .Error (w , fmt .Sprintf ("Failed to load repository: %v" , err ), http .StatusInternalServerError )
422+
415423 return
416424 }
417425
@@ -431,6 +439,7 @@ func affectedCommitsHandler(w http.ResponseWriter, r *http.Request) {
431439 err := json .NewDecoder (r .Body ).Decode (& body )
432440 if err != nil {
433441 http .Error (w , fmt .Sprintf ("Error decoding JSON: %v" , err ), http .StatusBadRequest )
442+
434443 return
435444 }
436445 defer r .Body .Close ()
@@ -468,6 +477,7 @@ func affectedCommitsHandler(w http.ResponseWriter, r *http.Request) {
468477 // Limit and fixed/last_affected shouldn't exist in the same request as it doesn't make sense
469478 if (len (fixed ) > 0 || len (lastAffected ) > 0 ) && len (limit ) > 0 {
470479 http .Error (w , "Limit and fixed/last_affected shouldn't exist in the same request" , http .StatusBadRequest )
480+
471481 return
472482 }
473483
@@ -479,9 +489,11 @@ func affectedCommitsHandler(w http.ResponseWriter, r *http.Request) {
479489 logger .Error ("Error fetching blob" , slog .String ("url" , url ), slog .Any ("error" , err ))
480490 if isAuthError (err ) {
481491 http .Error (w , fmt .Sprintf ("Error fetching blob: %v" , err ), http .StatusForbidden )
492+
482493 return
483494 }
484495 http .Error (w , fmt .Sprintf ("Error fetching blob: %v" , err ), http .StatusInternalServerError )
496+
485497 return
486498 }
487499
@@ -495,6 +507,7 @@ func affectedCommitsHandler(w http.ResponseWriter, r *http.Request) {
495507 if err != nil {
496508 logger .Error ("Failed to load repository" , slog .String ("url" , url ), slog .Any ("error" , err ))
497509 http .Error (w , fmt .Sprintf ("Failed to load repository: %v" , err ), http .StatusInternalServerError )
510+
498511 return
499512 }
500513 repo := repoAny .(* Repository )
@@ -509,6 +522,7 @@ func affectedCommitsHandler(w http.ResponseWriter, r *http.Request) {
509522 if err != nil {
510523 logger .Error ("Error processing affected commits" , slog .String ("url" , url ), slog .Any ("error" , err ))
511524 http .Error (w , fmt .Sprintf ("Error processing affected commits: %v" , err ), http .StatusInternalServerError )
525+
512526 return
513527 }
514528
@@ -517,6 +531,7 @@ func affectedCommitsHandler(w http.ResponseWriter, r *http.Request) {
517531 if err := json .NewEncoder (w ).Encode (affectedCommits ); err != nil {
518532 logger .Error ("Error encoding affected commits" , slog .String ("url" , url ), slog .Any ("error" , err ))
519533 http .Error (w , fmt .Sprintf ("Error encoding affected commits: %v" , err ), http .StatusInternalServerError )
534+
520535 return
521536 }
522537 logger .Info ("Request completed successfully: /affected-commits" , slog .String ("url" , url ), slog .Duration ("duration" , time .Since (start )))
0 commit comments