Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 0 additions & 68 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ toml = { version = "1.1.2", default-features = false }
tower = { version = "0.5.2", default-features = false }
tower-layer = { version = "0.3.3", default-features = false }
tower-service = { version = "0.3.3", default-features = false }
tracing = { version = "0.1.41", default-features = false }
tracing-subscriber = { version = "0.3.20", default-features = false }
trait-variant = { version = "0.1.2", default-features = false }
trybuild = { version = "1.0.114", default-features = false }
typeid = { version = "1.0.3", default-features = false }
Expand Down
2 changes: 0 additions & 2 deletions crates/cargo-heather/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ clap = { workspace = true, features = ["derive", "std", "help", "usage", "error-
ohno = { workspace = true, features = ["app-err"] }
serde = { workspace = true, features = ["derive", "alloc"] }
toml = { workspace = true, features = ["parse", "display", "serde"] }
tracing = { workspace = true }
tracing-subscriber = { workspace = true, features = ["fmt"] }
walkdir = { workspace = true }

[dev-dependencies]
Expand Down
3 changes: 1 addition & 2 deletions crates/cargo-heather/src/bin/cargo-heather/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use std::path::{Path, PathBuf};
use cargo_heather::HeatherError;
use cargo_heather::license;
use serde::Deserialize;
use tracing::info;

/// The default configuration file name.
pub(crate) const CONFIG_FILE_NAME: &str = ".cargo-heather.toml";
Expand Down Expand Up @@ -87,7 +86,7 @@ pub(crate) fn load_config(project_dir: &Path) -> Result<HeatherConfig, HeatherEr
if cargo_toml_path.exists()
&& let Some(config) = try_load_from_cargo_toml(&cargo_toml_path)?
{
info!("No {} found, using license from Cargo.toml.", CONFIG_FILE_NAME);
println!("No {CONFIG_FILE_NAME} found, using license from Cargo.toml.");
return Ok(config);
}

Expand Down
8 changes: 0 additions & 8 deletions crates/cargo-heather/src/bin/cargo-heather/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,10 @@ mod scanner;

use clap::Parser;
use ohno::AppError;
use tracing_subscriber::fmt::format::FmtSpan;

use crate::cli::CargoCli;

fn main() -> Result<(), AppError> {
tracing_subscriber::fmt()
.with_target(false)
.with_level(false)
.with_span_events(FmtSpan::NONE)
.without_time()
.init();

let CargoCli::Heather(args) = CargoCli::parse();
run::run(&args)
}
21 changes: 10 additions & 11 deletions crates/cargo-heather/src/bin/cargo-heather/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use std::path::{Path, PathBuf};

use cargo_heather::{CheckResult, CommentStyle, FileKind, HeatherError};
use ohno::AppError;
use tracing::info;

use crate::cli::HeatherArgs;
use crate::config::{self, HeatherConfig};
Expand All @@ -24,11 +23,11 @@ pub(crate) fn run(args: &HeatherArgs) -> Result<(), AppError> {
let files = scanner::find_source_files(&project_dir, Some(&config_path), &config);

if files.is_empty() {
info!("No source files found in '{}'.", project_dir.display());
println!("No source files found in '{}'.", project_dir.display());
return Ok(());
}

info!("Checking {} file(s)...", files.len());
println!("Checking {} file(s)...", files.len());

if args.fix {
run_fix(&files, &config, &project_dir)?;
Expand Down Expand Up @@ -69,13 +68,13 @@ fn run_check(files: &[PathBuf], config: &HeatherConfig, project_dir: &Path) -> R
match &result {
CheckResult::Ok => {}
CheckResult::Missing => {
info!(" MISSING header: {}", relative.display());
println!(" MISSING header: {}", relative.display());
failures += 1;
}
CheckResult::Mismatch { expected, actual } => {
info!(" MISMATCH header: {}", relative.display());
println!(" MISMATCH header: {}", relative.display());
for line in format_mismatch_details(expected, actual).lines() {
info!("{line}");
println!("{line}");
}
failures += 1;
}
Expand All @@ -86,7 +85,7 @@ fn run_check(files: &[PathBuf], config: &HeatherConfig, project_dir: &Path) -> R
ohno::bail!(HeatherError::ValidationFailed(failures));
}

info!("All {checked} file(s) have correct license headers.");
println!("All {checked} file(s) have correct license headers.");
Ok(())
}

Expand All @@ -111,23 +110,23 @@ fn run_fix(files: &[PathBuf], config: &HeatherConfig, project_dir: &Path) -> Res
path: path.clone(),
source: e,
})?;
info!(" Fixed (added header): {}", relative.display());
println!(" Fixed (added header): {}", relative.display());
fixed_count += 1;
}
CheckResult::Mismatch { .. } => {
std::fs::write(path, &output).map_err(|e| HeatherError::FileRead {
path: path.clone(),
source: e,
})?;
info!(" Fixed (replaced header): {}", relative.display());
println!(" Fixed (replaced header): {}", relative.display());
fixed_count += 1;
}
}
}

match fixed_count {
0 => info!("All files already have correct headers."),
n => info!("Fixed {n} file(s)."),
0 => println!("All files already have correct headers."),
n => println!("Fixed {n} file(s)."),
}

Ok(fixed_count)
Expand Down
Loading