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

Function conflicts

atomic-cli/src/commands/rpc.rs:4719–4787  ·  view source on GitHub ↗

`atomic conflicts` over ListConflicts — render parity: kind, line, sides ride the add-only ConflictInfo fields.

(short: bool)

Source from the content-addressed store, hash-verified

4717/// `atomic conflicts` over ListConflicts — render parity: kind, line,
4718/// sides ride the add-only ConflictInfo fields.
4719pub fn conflicts(short: bool) -> CliResult<bool> {
4720 let Some(session) = Service::open()? else {
4721 return Ok(false);
4722 };
4723 let request = pb::ListConflictsRequest {
4724 repository: Some(session.reference.clone()),
4725 };
4726 let response = session.list_conflicts(request)?;
4727
4728 if short {
4729 for conflict in &response.conflicts {
4730 let line = conflict
4731 .line
4732 .map(|l| l.to_string())
4733 .unwrap_or_else(|| "-".into());
4734 println!(
4735 "{}:{}:{}",
4736 conflict.path,
4737 line,
4738 conflict.kind.as_deref().unwrap_or("-")
4739 );
4740 }
4741 return Ok(true);
4742 }
4743 if response.conflicts.is_empty() {
4744 print_success("No conflicts.");
4745 return Ok(true);
4746 }
4747 let file_word = if response.conflicts.len() == 1 {
4748 "file"
4749 } else {
4750 "files"
4751 };
4752 // Group by path for the render (the wire is per-record).
4753 let mut by_path: std::collections::BTreeMap<&str, Vec<&pb::ConflictInfo>> =
4754 std::collections::BTreeMap::new();
4755 for conflict in &response.conflicts {
4756 by_path.entry(&conflict.path).or_default().push(conflict);
4757 }
4758 println!(
4759 "{}",
4760 crate::output::warning(&format!("{} conflicted {}:", by_path.len(), file_word))
4761 );
4762 println!();
4763 for (path, records) in &by_path {
4764 println!("\t{path}");
4765 for record in records {
4766 let where_ = match record.line {
4767 Some(line) => format!("line {line}"),
4768 None => "unknown line".to_string(),
4769 };
4770 let kind = record.kind.as_deref().unwrap_or("conflict");
4771 if record.sides.is_empty() {
4772 println!("\t {kind} conflict at {where_}");
4773 } else {
4774 let sides = record
4775 .sides
4776 .iter()

Callers 1

runMethod · 0.85

Calls 9

print_successFunction · 0.85
print_hintFunction · 0.85
openFunction · 0.50
cloneMethod · 0.45
list_conflictsMethod · 0.45
is_emptyMethod · 0.45
lenMethod · 0.45
pushMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected