Skip to content

Commit

Permalink
Do not require qlty.toml for coverage command (#1194)
Browse files Browse the repository at this point in the history
Use default config options if qlty.toml is not present.
  • Loading branch information
lsegal authored Nov 20, 2024
1 parent 6b43ce9 commit f8704dc
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions qlty-cli/src/commands/coverage/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::Result;
use clap::Args;
use console::style;
use indicatif::HumanBytes;
use qlty_config::Workspace;
use qlty_config::{QltyConfig, Workspace};
use qlty_coverage::eprintln_unless;
use qlty_coverage::formats::Formats;
use qlty_coverage::print::{print_report_as_json, print_report_as_text};
Expand Down Expand Up @@ -77,9 +77,6 @@ impl Publish {
pub fn execute(&self, _args: &crate::Arguments) -> Result<CommandSuccess, CommandError> {
self.print_initial_messages();

let workspace = Workspace::new()?;
workspace.fetch_sources()?;

let token = match self.load_auth_token() {
Ok(token) => token,
Err(err) => {
Expand All @@ -90,7 +87,7 @@ impl Publish {

eprintln_unless!(self.quiet, " Retrieving CI metadata...");
let plan = Planner::new(
&workspace.config()?,
&Self::load_config(),
&Settings {
override_build_id: self.override_build_id.clone(),
override_commit_sha: self.override_commit_sha.clone(),
Expand Down Expand Up @@ -217,4 +214,16 @@ impl Publish {
print_report_as_text(report)
}
}

fn load_config() -> QltyConfig {
if let Ok(workspace) = Workspace::new() {
if let Ok(cfg) = workspace.config() {
cfg
} else {
QltyConfig::default()
}
} else {
QltyConfig::default()
}
}
}

0 comments on commit f8704dc

Please sign in to comment.