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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ All notable changes to this project will be documented in this file.
* `attrs.disk_file_created_year`, `attrs.git_file_created_year`, and `attrs.git_file_modified_year` are now integers instead of strings. Most use cases should not be affected.
* `attrs.git_file_created_year` is now set even if the file is not tracked by Git. In this case, it will be set to the current year (as if it were committed now).
* `attrs.git_file_modified_year` is now overwritten if the file is modified but not committed by Git. In this case, it will be set to the current year (as if it were committed now).
* `attrs.disk_file_created_year` is then soft-deprecated. It will still be set, but it is recommended to use `attrs.git_file_created_year` and `attrs.git_file_modified_year` directly instead.
* `attrs.disk_file_created_year` is then soft-deprecated. It can still be set, but it is recommended to use `attrs.git_file_created_year` and `attrs.git_file_modified_year` directly instead.

The semantic changes above are breaking, but they should not affect most users and should always be what you want.

Expand All @@ -18,6 +18,10 @@ The semantic changes above are breaking, but they should not affect most users a
2. The baseDir configured.
3. The current working directory.

## Improvements

* If `--config` is not specified, HawkEye will now search for `.licenserc.toml` in addition to `licenserc.toml`.

## [6.3.0] 2025-10-09

### New features
Expand Down
16 changes: 15 additions & 1 deletion cli/src/subcommand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,5 +306,19 @@ fn check_unknown_files(unknown: &[String], fail_if_unknown: bool) -> bool {
}

fn default_config() -> PathBuf {
PathBuf::new().join("licenserc.toml")
let candidates = [
PathBuf::from("licenserc.toml"),
PathBuf::from(".licenserc.toml"),
];

for path in &candidates {
if path.exists() {
return path.clone();
}
}

panic!(
"cannot find config file in any of the default locations: {:?}",
candidates.iter().map(|p| p.display()).collect::<Vec<_>>()
);
}
2 changes: 1 addition & 1 deletion fmt/src/document/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl DocumentFactory {
.definitions
.get(&header_type)
.ok_or_else(|| io::Error::other(format!("header type {header_type} not found")))
.with_context(|| format!("cannot to create document: {}", filepath.display()))?;
.with_context(|| format!("cannot create document: {}", filepath.display()))?;

let props = self.properties.clone();

Expand Down
5 changes: 2 additions & 3 deletions fmt/src/document/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@ impl Document {
log::debug!("skip non-textual file: {}", filepath.display());
Ok(None)
} else {
Err(e).with_context(|| {
format!("cannot to create document: {}", filepath.display())
})
Err(e)
.with_context(|| format!("cannot create document: {}", filepath.display()))
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions fmt/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use std::path::PathBuf;
use anyhow::bail;
use anyhow::Context;
use gix::bstr::BStr;
use gix::status::Item;
use gix::Repository;

use crate::config;
Expand Down Expand Up @@ -173,11 +174,14 @@ pub fn resolve_file_attrs(

// process dirty working tree
let status_platform = repo.status(gix::progress::Discard)?;
let status_iter = status_platform.into_index_worktree_iter(None)?;
let status_iter = status_platform.into_iter(None)?;
let now = gix::date::Time::now_local_or_utc();
for item in status_iter {
let item = item.context("failed to check git status item")?;
let rel_path = item.rela_path();
let rel_path = match &item {
Item::IndexWorktree(item) => item.rela_path(),
Item::TreeIndex(item) => item.location(),
};
Comment on lines -176 to +184

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed in #199 (comment), the dirty state can be either:

  1. In the working tree, i.e., not yet git add-ed
  2. In the index, i.e., git add-ed but not yet committed.

into_index_worktree_iter returns only the diff between the index and the working tree, while into_iter returns all the diffs between the head-tree and the index, and the index and the working tree.

update_attrs(rel_path, now, current_username.as_str());
}

Expand Down