diff --git a/packages/server/src/artifact/checkin/input.rs b/packages/server/src/artifact/checkin/input.rs index 75e879c50..94eb1e291 100644 --- a/packages/server/src/artifact/checkin/input.rs +++ b/packages/server/src/artifact/checkin/input.rs @@ -397,6 +397,19 @@ impl Server { Some(analysis.imports) }; + // Pre-emptively pull tags for the set of imports. + if let Some(imports) = &imports { + let imports = imports.clone(); + let server = self.clone(); + tokio::spawn(async move { + server + .pull_tags_from_imports(imports) + .await + .inspect_err(|error| tracing::error!(%error, "failed to pull tags")) + .ok(); + }); + } + // Try and get the references of this file in the lockfile, if it exists. let resolved_references = 'a: { // Break if no lockfile is present. @@ -696,6 +709,29 @@ impl Server { } } +impl Server { + async fn pull_tags_from_imports( + &self, + imports: impl IntoIterator, + ) -> tg::Result<()> { + imports + .into_iter() + .filter_map(|import| { + let server = self.clone(); + let remote = import + .reference + .options() + .and_then(|options| options.remote.clone()); + let pattern = import.reference.item().try_unwrap_tag_ref().ok()?.clone(); + let future = async move { server.pull_tag(pattern, remote).await }; + Some(future) + }) + .collect::>() + .try_collect() + .await + } +} + impl Graph { // Find the roots of every node. fn find_roots(&mut self) { diff --git a/packages/server/src/tag.rs b/packages/server/src/tag.rs index 365f274be..6003d58d7 100644 --- a/packages/server/src/tag.rs +++ b/packages/server/src/tag.rs @@ -1,4 +1,5 @@ pub mod delete; pub mod get; pub mod list; +pub mod pull; pub mod put;