Skip to content

Commit 5a9496e

Browse files
Fix 'generated file edit' detection
1 parent be31a05 commit 5a9496e

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/main.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -502,9 +502,14 @@ fn enqueue_readme_jobs(
502502

503503
// Check if this README is staged and would be modified
504504
if staged_files.clean.contains(&readme_path) {
505+
// Get the relative path for git commands (git show doesn't like absolute paths)
506+
let relative_path = readme_path
507+
.strip_prefix(&workspace_dir)
508+
.unwrap_or(&readme_path);
509+
505510
// Get the staged content
506511
let staged_content = command_with_color("git")
507-
.args(["show", &format!(":{}", readme_path.display())])
512+
.args(["show", &format!(":{}", relative_path.display())])
508513
.output()
509514
.ok()
510515
.filter(|o| o.status.success())
@@ -2241,6 +2246,7 @@ fn collect_staged_files() -> io::Result<StagedFiles> {
22412246
}
22422247
let stdout = String::from_utf8_lossy(&output.stdout);
22432248
let mut clean = Vec::new();
2249+
let cwd = std::env::current_dir()?;
22442250

22452251
for line in stdout.lines() {
22462252
// E.g. "M src/main.rs", "A foo.rs", "AM foo/bar.rs"
@@ -2261,12 +2267,14 @@ fn collect_staged_files() -> io::Result<StagedFiles> {
22612267

22622268
// Staged and not dirty (to be formatted/committed)
22632269
if x != ' ' && x != '?' && y == ' ' {
2270+
// Convert relative path to absolute for consistent comparison
2271+
let abs_path = cwd.join(&path);
22642272
log::debug!(
22652273
"{} {}",
22662274
"-> clean (staged, not dirty):".green().bold(),
2267-
path.as_str().blue()
2275+
abs_path.display().to_string().blue()
22682276
);
2269-
clean.push(PathBuf::from(&path));
2277+
clean.push(abs_path);
22702278
}
22712279
}
22722280
Ok(StagedFiles { clean })

0 commit comments

Comments
 (0)