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

Method run

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 11

conflictsFunction · 0.85
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.45
is_emptyMethod · 0.45
lenMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected