@@ -34,9 +34,9 @@ async fn last_commit_from_pr(client: &Client,
34
34
json_obj)
35
35
) ;
36
36
}
37
- None => { return Err ( PreviewerError :: ResponseContentError (
38
- "No commits found" . to_owned ( ) ,
39
- json_obj) ) }
37
+ None => { Err ( PreviewerError :: ResponseContentError (
38
+ "No commits found" . to_owned ( ) ,
39
+ json_obj) ) }
40
40
}
41
41
}
42
42
@@ -47,9 +47,9 @@ async fn last_commit_from_pr(client: &Client,
47
47
fn extract_run_id_from_detail_url ( url : & str ) -> Result < u64 , PreviewerError > {
48
48
let pattern = "/actions/runs/" ;
49
49
50
- if let Some ( run_id_start_idx) = url. find ( & pattern) {
50
+ if let Some ( run_id_start_idx) = url. find ( pattern) {
51
51
let url_end = & url[ run_id_start_idx + pattern. len ( ) ..] ;
52
- if let Some ( run_id_end_idx) = url_end. find ( "/" ) {
52
+ if let Some ( run_id_end_idx) = url_end. find ( '/' ) {
53
53
if let Ok ( run_id) = url_end[ ..run_id_end_idx] . parse :: < u64 > ( ) {
54
54
return Ok ( run_id) ;
55
55
}
@@ -70,7 +70,7 @@ async fn run_id_from_commit(client: &Client,
70
70
. and_then ( |jobs| jobs. iter ( ) . find ( |job| job[ "name" ] == "Doc Build and Upload" ) ) {
71
71
Some ( job) => {
72
72
if let Some ( detail_url) = job[ "details_url" ] . as_str ( ) {
73
- extract_run_id_from_detail_url ( & detail_url)
73
+ extract_run_id_from_detail_url ( detail_url)
74
74
} else {
75
75
Err ( PreviewerError :: ResponseContentError (
76
76
"details_url not found" . to_owned ( ) ,
@@ -97,21 +97,21 @@ async fn artifact_url_from_run_id(client: &Client,
97
97
Some ( artifacts) => {
98
98
if artifacts. len ( ) == 1 {
99
99
if let Some ( artifact_url) = artifacts[ 0 ] [ "archive_download_url" ] . as_str ( ) {
100
- return Ok ( artifact_url. to_owned ( ) ) ;
100
+ Ok ( artifact_url. to_owned ( ) )
101
101
} else {
102
- return Err ( PreviewerError :: ResponseContentError (
103
- "artifact url is not a string" . to_owned ( ) ,
104
- json_obj) ) ;
102
+ Err ( PreviewerError :: ResponseContentError (
103
+ "artifact url is not a string" . to_owned ( ) ,
104
+ json_obj) )
105
105
}
106
106
} else {
107
- return Err ( PreviewerError :: ResponseContentError (
108
- format ! ( "Expected 1 artifact, {} found" , artifacts. len( ) ) ,
109
- json_obj) ) ;
107
+ Err ( PreviewerError :: ResponseContentError (
108
+ format ! ( "Expected 1 artifact, {} found" , artifacts. len( ) ) ,
109
+ json_obj) )
110
110
}
111
111
}
112
- None => { return Err ( PreviewerError :: ResponseContentError (
113
- "no artifacts found" . to_owned ( ) ,
114
- json_obj) ) }
112
+ None => { Err ( PreviewerError :: ResponseContentError (
113
+ "no artifacts found" . to_owned ( ) ,
114
+ json_obj) ) }
115
115
}
116
116
}
117
117
@@ -124,7 +124,7 @@ async fn download_artifact(client: &Client,
124
124
let mut resp = client. get ( url) . send ( ) . await ?;
125
125
let artifact_content = resp. body ( ) . limit ( max_artifact_size) . await ?;
126
126
let mut zip_archive = zip:: ZipArchive :: new ( Cursor :: new ( artifact_content) ) ?;
127
- zip_archive. extract ( & target_dir) ?;
127
+ zip_archive. extract ( target_dir) ?;
128
128
129
129
// Temporary creating a file inside the directory, so the directory mtime is updated
130
130
// This will make sure the directory is not cleaned up when it has recent changes
@@ -144,24 +144,24 @@ pub async fn publish_artifact(client: &Client,
144
144
145
145
log:: info!( "[PR {}] Preview requested" , pull_request_number) ;
146
146
147
- let last_commit = last_commit_from_pr ( & client,
148
- & base_api_url,
147
+ let last_commit = last_commit_from_pr ( client,
148
+ base_api_url,
149
149
pull_request_number) . await ?;
150
150
log:: info!( "[PR {}] Last commit: {}" , pull_request_number, last_commit) ;
151
151
152
- let run_id = run_id_from_commit ( & client,
153
- & base_api_url,
152
+ let run_id = run_id_from_commit ( client,
153
+ base_api_url,
154
154
& last_commit) . await ?;
155
155
log:: info!( "[PR {}] Run id: {}" , pull_request_number, run_id) ;
156
156
157
- let artifact_url = artifact_url_from_run_id ( & client,
158
- & base_api_url,
157
+ let artifact_url = artifact_url_from_run_id ( client,
158
+ base_api_url,
159
159
run_id) . await ?;
160
160
log:: info!( "[PR {}] Artifact url: {}" , pull_request_number, artifact_url) ;
161
161
162
162
163
163
log:: info!( "[PR {}] Starting artifact download" , pull_request_number) ;
164
- download_artifact ( & client, & artifact_url, & target_dir, max_artifact_size) . await ?;
164
+ download_artifact ( client, & artifact_url, target_dir, max_artifact_size) . await ?;
165
165
log:: info!( "[PR {}] Artifact downloaded to {:?}" , pull_request_number, target_dir) ;
166
166
167
167
Ok ( ( ) )
0 commit comments