Build the Atomic-remote closure source from a configured remote (CB-10B review R9: the bootstrap consumes its promised transport sources). `None` when the remote is absent or not an HTTP remote.
(
repo: &Repository,
remote_name: &str,
)
| 661 | /// (CB-10B review R9: the bootstrap consumes its promised transport |
| 662 | /// sources). `None` when the remote is absent or not an HTTP remote. |
| 663 | pub(crate) fn for_configured_remote( |
| 664 | repo: &Repository, |
| 665 | remote_name: &str, |
| 666 | ) -> Result<Option<Self>, atomic_repository::RepositoryError> { |
| 667 | let config = repo.load_remotes()?; |
| 668 | let Some(entry) = config.get(remote_name) else { |
| 669 | return Ok(None); |
| 670 | }; |
| 671 | let runtime = tokio::runtime::Builder::new_current_thread() |
| 672 | .enable_all() |
| 673 | .build() |
| 674 | .map_err( |
| 675 | |error| atomic_repository::RepositoryError::InvalidOperation { |
| 676 | message: format!("cannot start HTTP runtime: {error}"), |
| 677 | }, |
| 678 | )?; |
| 679 | let remote = atomic_remote::HttpRemote::new(&entry.url).map_err(|error| { |
| 680 | atomic_repository::RepositoryError::InvalidOperation { |
| 681 | message: format!("cannot connect to the Atomic remote '{remote_name}': {error}"), |
| 682 | } |
| 683 | })?; |
| 684 | Ok(Some(Self { remote })) |
| 685 | } |
| 686 | } |
| 687 | |
| 688 | #[cfg(test)] |
nothing calls this directly
no test coverage detected