From a46202c17fa05648fb7a7460c2d343c137d99f56 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Wed, 13 Nov 2024 14:20:29 -0800 Subject: [PATCH] Fix vcs context. --- crates/workspace/src/workspace_builder.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/crates/workspace/src/workspace_builder.rs b/crates/workspace/src/workspace_builder.rs index 958eb60951..1f0f86ce04 100644 --- a/crates/workspace/src/workspace_builder.rs +++ b/crates/workspace/src/workspace_builder.rs @@ -191,11 +191,19 @@ impl<'app> WorkspaceBuilder<'app> { ..Default::default() }; - // This is only in a conditional for tests! + // These are only in conditionals for tests that don't have git + // initialized, which is most of them! if let Some(vcs) = &context.vcs { - graph_context.vcs_branch = vcs.get_local_branch().await?; - graph_context.vcs_repository = vcs.get_repository_slug().await?; - graph_context.vcs_revision = vcs.get_local_branch_revision().await?; + if vcs.is_enabled() { + graph_context.vcs_branch = vcs.get_local_branch().await?; + graph_context.vcs_revision = vcs.get_local_branch_revision().await?; + + if let Ok(repo) = vcs.get_repository_slug().await { + graph_context.vcs_repository = repo; + } + } else { + graph_context.vcs_branch = vcs.get_default_branch().await?; + } } let project_metadata = self