From b6ec015cf4cd61a588a80c214d933a248f6a20c1 Mon Sep 17 00:00:00 2001 From: david-castaneda Date: Wed, 14 Jun 2023 20:15:27 -0400 Subject: [PATCH] Fix `source_location` access in subgraph check; minor updates to task styling --- .../src/operations/subgraph/check_workflow/runner.rs | 8 ++++---- crates/rover-client/src/shared/check_response.rs | 7 +++---- src/error/mod.rs | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/crates/rover-client/src/operations/subgraph/check_workflow/runner.rs b/crates/rover-client/src/operations/subgraph/check_workflow/runner.rs index 29815e60e..51fc1d552 100644 --- a/crates/rover-client/src/operations/subgraph/check_workflow/runner.rs +++ b/crates/rover-client/src/operations/subgraph/check_workflow/runner.rs @@ -257,11 +257,11 @@ fn get_lint_response_from_result( Some(result) => { let mut diagnostics = Vec::with_capacity(result.diagnostics.len()); for diagnostic in result.diagnostics { - let mut start_line = 0; // loc 0 is supergraph and 1 is subgraph - if let Some(start) = &diagnostic.source_locations[1].start { - start_line = start.line; - } + let start_line = match diagnostic.source_locations.len() { + 2 => diagnostic.source_locations[1].start.clone().unwrap().line, + _ => diagnostic.source_locations[0].start.clone().unwrap().line, + }; diagnostics.push(Diagnostic { level: diagnostic.level.to_string(), message: diagnostic.message, diff --git a/crates/rover-client/src/shared/check_response.rs b/crates/rover-client/src/shared/check_response.rs index f040215ee..23aa4f062 100644 --- a/crates/rover-client/src/shared/check_response.rs +++ b/crates/rover-client/src/shared/check_response.rs @@ -36,39 +36,38 @@ impl CheckWorkflowResponse { } else { msg.push_str("There were no changes detected in the composed schema.") } - msg.push('\n'); } if let Some(operations_response) = &self.maybe_operations_response { if !operations_response.changes.is_empty() { + msg.push('\n'); msg.push_str(&Self::task_title( "Operation Check", operations_response.task_status.clone(), )); msg.push_str(operations_response.get_output().as_str()); - msg.push('\n'); } } if let Some(lint_response) = &self.maybe_lint_response { if !lint_response.diagnostics.is_empty() { + msg.push('\n'); msg.push_str(&Self::task_title( "Lint Check", lint_response.task_status.clone(), )); msg.push_str(lint_response.get_output().as_str()); - msg.push('\n'); } } if let Some(downstream_response) = &self.maybe_downstream_response { if !downstream_response.blocking_variants.is_empty() { + msg.push('\n'); msg.push_str(&Self::task_title( "Downstream Check", downstream_response.task_status.clone(), )); msg.push_str(downstream_response.get_output().as_str()); - msg.push('\n'); } } diff --git a/src/error/mod.rs b/src/error/mod.rs index 86daba694..853a97dc7 100644 --- a/src/error/mod.rs +++ b/src/error/mod.rs @@ -89,7 +89,7 @@ impl RoverError { check_response, }) = self.error.downcast_ref::() { - stdoutln!("{}", check_response.to_output())?; + stdoutln!("{}\n", check_response.to_output())?; } stderr!("{}", self)?;