@@ -17,7 +17,7 @@ use crate::{
1717 cli:: { FeedbackInput , LinesChangedOnly } ,
1818 common_fs:: { FileFilter , FileObj } ,
1919 git:: parse_diff_from_buf,
20- rest_api:: { RestApiRateLimitHeaders , COMMENT_MARKER , USER_AGENT } ,
20+ rest_api:: { send_api_request , RestApiRateLimitHeaders , COMMENT_MARKER , USER_AGENT } ,
2121} ;
2222
2323use super :: {
@@ -94,14 +94,9 @@ impl GithubApiClient {
9494 while let Some ( ref endpoint) = url {
9595 let request =
9696 Self :: make_api_request ( & self . client , endpoint. as_str ( ) , Method :: GET , None , None ) ?;
97- let response = Self :: send_api_request (
98- self . client . clone ( ) ,
99- request,
100- self . rate_limit_headers . clone ( ) ,
101- 0 ,
102- )
103- . await
104- . with_context ( || "Failed to get paginated list of changed files" ) ?;
97+ let response = send_api_request ( & self . client , request, & self . rate_limit_headers )
98+ . await
99+ . with_context ( || "Failed to get paginated list of changed files" ) ?;
105100 url = Self :: try_next_page ( response. headers ( ) ) ;
106101 let files_list = if self . event_name != "pull_request" {
107102 let json_value: PushEventFiles = serde_json:: from_str ( & response. text ( ) . await ?)
@@ -233,14 +228,7 @@ impl GithubApiClient {
233228 Some ( serde_json:: json!( & payload) . to_string ( ) ) ,
234229 None ,
235230 ) ?;
236- match Self :: send_api_request (
237- self . client . clone ( ) ,
238- request,
239- self . rate_limit_headers . to_owned ( ) ,
240- 0 ,
241- )
242- . await
243- {
231+ match send_api_request ( & self . client , request, & self . rate_limit_headers ) . await {
244232 Ok ( response) => {
245233 Self :: log_response ( response, "Failed to post thread comment" ) . await ;
246234 }
@@ -270,13 +258,7 @@ impl GithubApiClient {
270258 while let Some ( ref endpoint) = comments_url {
271259 let request =
272260 Self :: make_api_request ( & self . client , endpoint. as_str ( ) , Method :: GET , None , None ) ?;
273- let result = Self :: send_api_request (
274- self . client . clone ( ) ,
275- request,
276- self . rate_limit_headers . to_owned ( ) ,
277- 0 ,
278- )
279- . await ;
261+ let result = send_api_request ( & self . client , request, & self . rate_limit_headers ) . await ;
280262 match result {
281263 Err ( e) => {
282264 log:: error!( "Failed to get list of existing thread comments: {e:?}" ) ;
@@ -330,11 +312,10 @@ impl GithubApiClient {
330312 None ,
331313 None ,
332314 ) ?;
333- match Self :: send_api_request (
334- self . client . clone ( ) ,
315+ match send_api_request (
316+ & self . client ,
335317 req,
336- self . rate_limit_headers . to_owned ( ) ,
337- 0 ,
318+ & self . rate_limit_headers ,
338319 )
339320 . await
340321 {
@@ -391,12 +372,7 @@ impl GithubApiClient {
391372 // if we got here, then we know that it is a self.pull_request is a valid value
392373 . join ( self . pull_request . to_string ( ) . as_str ( ) ) ?;
393374 let request = Self :: make_api_request ( & self . client , url. as_str ( ) , Method :: GET , None , None ) ?;
394- let response = Self :: send_api_request (
395- self . client . clone ( ) ,
396- request,
397- self . rate_limit_headers . clone ( ) ,
398- 0 ,
399- ) ;
375+ let response = send_api_request ( & self . client , request, & self . rate_limit_headers ) ;
400376
401377 let url = Url :: parse ( format ! ( "{}/" , url) . as_str ( ) ) ?. join ( "reviews" ) ?;
402378 let dismissal = self . dismiss_outdated_reviews ( & url) ;
@@ -462,22 +438,15 @@ impl GithubApiClient {
462438 dismissal. await ?; // free up the `url` variable
463439 let request = Self :: make_api_request (
464440 & self . client ,
465- url. clone ( ) ,
441+ url,
466442 Method :: POST ,
467443 Some (
468444 serde_json:: to_string ( & payload)
469445 . with_context ( || "Failed to serialize PR review to json string" ) ?,
470446 ) ,
471447 None ,
472448 ) ?;
473- match Self :: send_api_request (
474- self . client . clone ( ) ,
475- request,
476- self . rate_limit_headers . clone ( ) ,
477- 0 ,
478- )
479- . await
480- {
449+ match send_api_request ( & self . client , request, & self . rate_limit_headers ) . await {
481450 Ok ( response) => {
482451 if !response. status ( ) . is_success ( ) {
483452 Self :: log_response ( response, "Failed to post a new PR review" ) . await ;
@@ -496,13 +465,7 @@ impl GithubApiClient {
496465 while let Some ( ref endpoint) = url_ {
497466 let request =
498467 Self :: make_api_request ( & self . client , endpoint. as_str ( ) , Method :: GET , None , None ) ?;
499- let result = Self :: send_api_request (
500- self . client . clone ( ) ,
501- request,
502- self . rate_limit_headers . clone ( ) ,
503- 0 ,
504- )
505- . await ;
468+ let result = send_api_request ( & self . client , request, & self . rate_limit_headers ) . await ;
506469 match result {
507470 Err ( e) => {
508471 log:: error!( "Failed to get a list of existing PR reviews: {e:?}" ) ;
@@ -538,11 +501,10 @@ impl GithubApiClient {
538501 Some ( REVIEW_DISMISSAL . to_string ( ) ) ,
539502 None ,
540503 ) {
541- match Self :: send_api_request (
542- self . client . clone ( ) ,
504+ match send_api_request (
505+ & self . client ,
543506 req,
544- self . rate_limit_headers . clone ( ) ,
545- 0 ,
507+ & self . rate_limit_headers ,
546508 )
547509 . await
548510 {
0 commit comments