Compute diff between two git refs (matching TS `Snapshot.diffFull`). Runs `git diff --numstat --no-renames -- .` to get per-file addition/deletion counts, then `git diff --name-status --no-renames -- .` to determine whether each file was added, deleted, or modified.
(directory: &Path, from: &str, to: &str)
| 132 | /// addition/deletion counts, then `git diff --name-status --no-renames <from> <to> -- .` |
| 133 | /// to determine whether each file was added, deleted, or modified. |
| 134 | pub fn diff_full(directory: &Path, from: &str, to: &str) -> Result<Vec<super::FileDiff>> { |
| 135 | let git_dir = ensure_snapshot_repo(directory)?; |
| 136 | let numstat_output = git_output( |
| 137 | directory, |
| 138 | &git_dir, |
| 139 | &[ |
| 140 | "-c", |
| 141 | "core.autocrlf=false", |
| 142 | "-c", |
| 143 | "core.quotepath=false", |
| 144 | "diff", |
| 145 | "--no-ext-diff", |
| 146 | "--no-renames", |
| 147 | "--numstat", |
| 148 | from, |
| 149 | to, |
| 150 | "--", |
| 151 | ".", |
| 152 | ], |
| 153 | ); |
| 154 | |
| 155 | let mut diffs = Vec::new(); |
| 156 | |
| 157 | if let Ok(output) = numstat_output { |
| 158 | for line in String::from_utf8_lossy(&output.stdout).lines() { |
| 159 | if line.is_empty() { |
| 160 | continue; |
| 161 | } |
| 162 | let parts: Vec<&str> = line.split('\t').collect(); |
| 163 | if parts.len() >= 3 { |
| 164 | let is_binary = parts[0] == "-" && parts[1] == "-"; |
| 165 | let additions = if is_binary { |
| 166 | 0 |
| 167 | } else { |
| 168 | parts[0].parse::<u64>().unwrap_or(0) |
| 169 | }; |
| 170 | let deletions = if is_binary { |
| 171 | 0 |
| 172 | } else { |
| 173 | parts[1].parse::<u64>().unwrap_or(0) |
| 174 | }; |
| 175 | let path = parts[2].to_string(); |
| 176 | diffs.push(super::FileDiff { |
| 177 | path, |
| 178 | additions, |
| 179 | deletions, |
| 180 | }); |
| 181 | } |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | Ok(diffs) |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | impl Default for Snapshot { |
nothing calls this directly
no test coverage detected