Async implementation of the push command.
(&self)
| 312 | |
| 313 | /// Async implementation of the push command. |
| 314 | async fn run_async(&self) -> CliResult<()> { |
| 315 | // Find and open repository |
| 316 | let repo_root = find_repository_root()?; |
| 317 | let repo = Repository::open(&repo_root).map_err(CliError::Repository)?; |
| 318 | |
| 319 | // Resolve remote name, URL, and identity hint |
| 320 | let (remote_name, remote_url, identity_hint) = self.resolve_remote_url(&repo)?; |
| 321 | |
| 322 | // Determine views |
| 323 | let local_view = self.get_local_view(&repo); |
| 324 | let remote_view = self.get_remote_view(&local_view); |
| 325 | let default_remote_view = "dev".to_string(); |
| 326 | |
| 327 | // Print header |
| 328 | println!( |
| 329 | "Pushing to {} ({})", |
| 330 | style_view(&remote_name), |
| 331 | hint(&remote_url) |
| 332 | ); |
| 333 | |
| 334 | // Fail fast if we have no usable credentials for this remote. A push is |
| 335 | // a write that always requires auth; without a credential the server's |
| 336 | // negotiation endpoints return an ambiguous 404 (private projects are |
| 337 | // deliberately masked), which surfaces as a misleading "view not found". |
| 338 | // Catching the missing credential here gives the user an accurate, |
| 339 | // actionable error instead. |
| 340 | crate::commands::auth::check_push_credentials(&remote_url, identity_hint.as_deref())?; |
| 341 | |
| 342 | // Connect to remote |
| 343 | let spinner = create_spinner("Connecting to remote..."); |
| 344 | let config = self |
| 345 | .build_remote_config(&remote_url, identity_hint.as_deref()) |
| 346 | .await; |
| 347 | let remote = HttpRemote::with_config(&remote_url, config).map_err(|e| { |
| 348 | finish_error(&spinner, "Failed to connect"); |
| 349 | convert_remote_error(e, &remote_url) |
| 350 | })?; |
| 351 | finish_success(&spinner, "Connected"); |
| 352 | |
| 353 | // Query remote state |
| 354 | let spinner = create_spinner("Querying remote state..."); |
| 355 | let remote_state = remote.get_state(&remote_view).await.map_err(|e| { |
| 356 | finish_error(&spinner, "Failed to query state"); |
| 357 | convert_remote_error(e, &remote_url) |
| 358 | })?; |
| 359 | finish_success(&spinner, "Got remote state"); |
| 360 | |
| 361 | // Get the target view's full effective change set in dependency |
| 362 | // order. For a draft view this includes the changes inherited from |
| 363 | // its shared base, not just the draft's own delta — the remote view |
| 364 | // is flattened (shared) and needs the complete graph. Changes the |
| 365 | // remote already has are skipped by the delta/adopt logic below, so |
| 366 | // re-including the base is idempotent. Using `local_view` (not the |
| 367 | // current view) also ensures `--to-view` pushes the right view. |
| 368 | let spinner = create_spinner("Loading local history..."); |
| 369 | let local_entries = repo |
| 370 | .effective_history(Some(&local_view)) |
| 371 | .map_err(CliError::Repository)?; |
no test coverage detected