The dry-run preview, pure over its inputs — the same lines the local body prints, shared with the routed path (the wire's Status entries drive it; the status vocabulary maps to the local descriptions).
(entries: &[(FileStatus, String)], all: bool, files: &[String])
| 178 | /// body prints, shared with the routed path (the wire's Status entries |
| 179 | /// drive it; the status vocabulary maps to the local descriptions). |
| 180 | pub(crate) fn render_dry_run(entries: &[(FileStatus, String)], all: bool, files: &[String]) { |
| 181 | let mut has_changes = false; |
| 182 | |
| 183 | println!("Would record:"); |
| 184 | |
| 185 | for (status, path) in entries { |
| 186 | // Skip untracked unless --all |
| 187 | if matches!(status, FileStatus::Untracked) && !all { |
| 188 | continue; |
| 189 | } |
| 190 | |
| 191 | // Skip clean files |
| 192 | if matches!(status, FileStatus::Clean) { |
| 193 | continue; |
| 194 | } |
| 195 | |
| 196 | // Filter by specified files if any |
| 197 | if !files.is_empty() && !files.iter().any(|f| path.contains(f)) { |
| 198 | continue; |
| 199 | } |
| 200 | |
| 201 | has_changes = true; |
| 202 | let status_desc = match status { |
| 203 | FileStatus::Added => "new file:", |
| 204 | FileStatus::Modified => "modified:", |
| 205 | FileStatus::Deleted => "deleted: ", |
| 206 | FileStatus::Untracked => "new file:", |
| 207 | FileStatus::PendingUntrack => "untrack pending:", |
| 208 | FileStatus::TypeChanged => "typechange:", |
| 209 | FileStatus::PermissionsChanged => "permissions:", |
| 210 | FileStatus::Conflicted => "conflicted:", |
| 211 | FileStatus::Clean => continue, |
| 212 | }; |
| 213 | |
| 214 | println!(" {} {}", status_desc, path); |
| 215 | } |
| 216 | |
| 217 | if !has_changes { |
| 218 | println!(" (no changes to record)"); |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | impl Default for Record { |
| 223 | fn default() -> Self { |
no test coverage detected