MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / run

Method run

atomic-cli/src/commands/diff/command.rs:223–452  ·  view source on GitHub ↗

Execute the diff command. This method: 1. Finds and opens the repository 2. Gets the status of the working copy 3. Computes diffs for modified files 4. Displays the diffs in the requested format

(&self)

Source from the content-addressed store, hash-verified

221 /// 3. Computes diffs for modified files
222 /// 4. Displays the diffs in the requested format
223 fn run(&self) -> CliResult<()> {
224 // Find the repository root
225 let repo_root = find_repository_root()?;
226
227 // Open the repository
228 let repo =
229 Repository::open_readonly(&repo_root).map_err(|e| CliError::InvalidRepository {
230 reason: e.to_string(),
231 })?;
232
233 // Parse algorithm
234 let algorithm = self.parse_algorithm()?;
235
236 // Get output configuration
237 let config = self.get_output_config();
238
239 // If --change is specified, show the content of that specific change
240 if let Some(change_ref) = &self.change {
241 return self.show_change_diff(&repo, change_ref, &config);
242 }
243
244 // Get status to find modified files
245 let status_options = StatusOptions::default();
246 let status = repo
247 .status(status_options)
248 .map_err(|e| CliError::Internal(e.into()))?;
249
250 // Collect files to diff
251 let files_to_diff: Vec<_> = if self.files.is_empty() {
252 // Diff all modified and added files
253 let mut entries: Vec<_> = status
254 .modified()
255 .chain(status.added())
256 .chain(status.deleted())
257 .map(|e| (e.path().to_path_buf(), e.status()))
258 .collect();
259
260 // Include untracked files if --untracked flag is set
261 if self.untracked {
262 entries.extend(
263 status
264 .untracked()
265 .map(|e| (e.path().to_path_buf(), e.status())),
266 );
267 }
268
269 entries
270 } else {
271 // Diff only specified files
272 self.files
273 .iter()
274 .filter_map(|path| {
275 let path_buf = PathBuf::from(path);
276 // Find the file in status
277 status
278 .entries()
279 .iter()
280 .find(|e| e.path() == path_buf)

Calls 15

find_repository_rootFunction · 0.85
deletedFunction · 0.85
addedFunction · 0.85
diff_textFunction · 0.85
modifiedFunction · 0.85
build_hunks_from_diffFunction · 0.85
get_output_configMethod · 0.80
show_change_diffMethod · 0.80
extendMethod · 0.80
untrackedMethod · 0.80
entriesMethod · 0.80
print_no_changesMethod · 0.80