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

Method run

atomic-cli/src/commands/conflicts.rs:45–108  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

43
44impl Command for Conflicts {
45 fn run(&self) -> CliResult<()> {
46 let repo_root = find_repository_root()?;
47 let repo = crate::commands::open_readonly_repository(&repo_root).map_err(|e| {
48 CliError::InvalidRepository {
49 reason: e.to_string(),
50 }
51 })?;
52
53 let conflicts = repo
54 .list_conflicts()
55 .map_err(|e| CliError::Internal(e.into()))?;
56
57 if self.short {
58 for (path, records) in &conflicts {
59 for c in records {
60 let line = c.line.map(|l| l.to_string()).unwrap_or_else(|| "-".into());
61 println!("{}:{}:{}", path, line, c.kind);
62 }
63 }
64 return Ok(());
65 }
66
67 if conflicts.is_empty() {
68 print_success("No conflicts.");
69 return Ok(());
70 }
71
72 let file_word = if conflicts.len() == 1 {
73 "file"
74 } else {
75 "files"
76 };
77 println!(
78 "{}",
79 warning(&format!("{} conflicted {}:", conflicts.len(), file_word))
80 );
81 print_blank();
82
83 for (path, records) in &conflicts {
84 println!("\t{}", style_path(path));
85 for c in records {
86 let where_ = match c.line {
87 Some(l) => format!("line {}", l),
88 None => "unknown line".to_string(),
89 };
90 if c.sides.is_empty() {
91 println!("\t {} conflict at {}", c.kind, where_);
92 } else {
93 let sides = c
94 .sides
95 .iter()
96 .map(|h| h.chars().take(12).collect::<String>())
97 .collect::<Vec<_>>()
98 .join(", ");
99 println!("\t {} conflict at {} between {}", c.kind, where_, sides);
100 }
101 }
102 }

Callers

nothing calls this directly

Calls 9

find_repository_rootFunction · 0.85
open_readonly_repositoryFunction · 0.85
print_successFunction · 0.85
print_blankFunction · 0.85
print_hintFunction · 0.85
list_conflictsMethod · 0.80
is_emptyMethod · 0.45
lenMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected