(
repo_url: String,
access_token: Option<String>,
settings: Option<GourceSettings>,
job_id: String,
job_store: web::Data<JobStore>,
)
| 187 | } |
| 188 | |
| 189 | async fn process_gource( |
| 190 | repo_url: String, |
| 191 | access_token: Option<String>, |
| 192 | settings: Option<GourceSettings>, |
| 193 | job_id: String, |
| 194 | job_store: web::Data<JobStore>, |
| 195 | ) -> Result<(), GourceError> { |
| 196 | let job_id_clone = job_id.clone(); |
| 197 | log_message( |
| 198 | log::Level::Info, |
| 199 | "Starting process_gource", |
| 200 | Some(&job_id_clone), |
| 201 | ); |
| 202 | let start_time = Instant::now(); |
| 203 | |
| 204 | update_job_status(&job_store, &job_id, ProgressStep::InitializingProject).await; |
| 205 | log_message( |
| 206 | log::Level::Info, |
| 207 | "Updated job status to InitializingProject", |
| 208 | Some(&job_id_clone), |
| 209 | ); |
| 210 | |
| 211 | let url = Url::parse(&repo_url).map_err(|_| GourceError::InvalidUrl)?; |
| 212 | let host = url.host_str().unwrap_or(""); |
| 213 | if !host.ends_with("github.com") { |
| 214 | if access_token.is_some() { |
| 215 | return Err(GourceError::UnsupportedRepository); |
| 216 | } |
| 217 | } |
| 218 | log_message( |
| 219 | log::Level::Info, |
| 220 | &format!("Validated repository URL: {}", repo_url), |
| 221 | Some(&job_id_clone), |
| 222 | ); |
| 223 | |
| 224 | let temp_dir = tempfile::TempDir::new().map_err(|_| GourceError::TempDirCreationFailed)?; |
| 225 | log_message( |
| 226 | log::Level::Info, |
| 227 | "Created temporary directory", |
| 228 | Some(&job_id_clone), |
| 229 | ); |
| 230 | |
| 231 | let clone_start = Instant::now(); |
| 232 | log_message( |
| 233 | log::Level::Info, |
| 234 | "Attempting to decrypt token", |
| 235 | Some(&job_id_clone), |
| 236 | ); |
| 237 | let decrypted_token = if let Some(encrypted_token) = access_token { |
| 238 | log_message( |
| 239 | log::Level::Info, |
| 240 | "Access token provided, attempting decryption", |
| 241 | Some(&job_id_clone), |
| 242 | ); |
| 243 | let secret_key = dotenv::var("SECRET_KEY") |
| 244 | .or_else(|_| std::env::var("SECRET_KEY")) |
| 245 | .expect("SECRET_KEY must be set in .env file or environment"); |
| 246 | log_message( |
no test coverage detected