Skip to content
This repository was archived by the owner on Apr 6, 2026. It is now read-only.

Commit 9acb6fe

Browse files
authored
fix(build2cmake): ignore untracked files when looking for modified files to suffix with _dirty (#280)
In the current flow, `build2cmake` might generates `CMake` files before this get called thus generating some changes (i.e. `statuses.is_empty() == false` if the build folder is in the source tree. Adding options in order to soften a bit the constraint
1 parent d509f5f commit 9acb6fe

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

build2cmake/src/torch/ops_identifier.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ fn git_identifier(target_dir: impl AsRef<Path>) -> Result<String> {
1919
let head = repo.head()?;
2020
let commit = head.peel_to_commit()?;
2121
let rev = commit.tree_id().to_string().chars().take(7).collect();
22-
let dirty = !repo.statuses(None)?.is_empty();
22+
23+
let mut status_options = git2::StatusOptions::new();
24+
status_options.include_untracked(false); // Ignore untracked files (like generated CMake files)
25+
status_options.exclude_submodules(true);
26+
let dirty = !repo.statuses(Some(&mut status_options))?.is_empty();
2327
Ok(if dirty { format!("{rev}_dirty") } else { rev })
2428
}
2529

0 commit comments

Comments
 (0)