git_policy_cli/
commit_no_change.rs1use super::path_bytes::path_message_text;
15
16pub const NO_CHANGE_CORE_ID: &str = "commit-normalization";
18
19pub const NO_CHANGE_CODE: &str = "no-change";
21
22pub fn no_change_message(conflicted: &[Vec<u8>]) -> String {
32 if conflicted.is_empty() {
33 return String::from(
34 "No commit created: normalization removed every selected change; matching worktree and index copies were reconciled. Hint: if you were committing only whitespace or final-newline edits, they were normalized away, so there is nothing to commit; run `git status` to confirm.",
35 );
36 }
37 let names: Vec<String> = conflicted.iter().map(|path| { return path_message_text(path.as_slice()); }).collect();
39 let listed: String = serde_json::to_string(&names).unwrap_or_default();
40 return format!(
41 "No commit created: normalization removed every selected change; index copies were reconciled, but worktree copies changed and were kept: {listed}. Compare them with HEAD before retrying. Hint: if you were committing only whitespace or final-newline edits, they were normalized away; `git diff HEAD -- <path>` shows what still differs."
42 );
43}
44
45#[cfg(test)]
47#[path = "commit_no_change_tests.rs"]
48mod tests;