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

Method run

atomic-cli/src/commands/diff/command.rs:223–453  ·  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 = crate::commands::open_readonly_repository(&repo_root).map_err(|e| {
229 CliError::InvalidRepository {
230 reason: e.to_string(),
231 }
232 })?;
233
234 // Parse algorithm
235 let algorithm = self.parse_algorithm()?;
236
237 // Get output configuration
238 let config = self.get_output_config();
239
240 // If --change is specified, show the content of that specific change
241 if let Some(change_ref) = &self.change {
242 return self.show_change_diff(&repo, change_ref, &config);
243 }
244
245 // Get status to find modified files
246 let status_options = StatusOptions::default();
247 let status = repo
248 .status(status_options)
249 .map_err(|e| CliError::Internal(e.into()))?;
250
251 // Collect files to diff
252 let files_to_diff: Vec<_> = if self.files.is_empty() {
253 // Diff all modified and added files
254 let mut entries: Vec<_> = status
255 .modified()
256 .chain(status.added())
257 .chain(status.deleted())
258 .map(|e| (e.path().to_path_buf(), e.status()))
259 .collect();
260
261 // Include untracked files if --untracked flag is set
262 if self.untracked {
263 entries.extend(
264 status
265 .untracked()
266 .map(|e| (e.path().to_path_buf(), e.status())),
267 );
268 }
269
270 entries
271 } else {
272 // Diff only specified files
273 self.files
274 .iter()
275 .filter_map(|path| {
276 let path_buf = PathBuf::from(path);
277 // Find the file in status
278 status
279 .entries()
280 .iter()

Calls 15

find_repository_rootFunction · 0.85
open_readonly_repositoryFunction · 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