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

Method run

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

Callers

nothing calls this directly

Calls 8

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