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

Function conflicts

atomic-cli/src/commands/rpc.rs:4679–4747  ·  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

4677/// `atomic conflicts` over ListConflicts — render parity: kind, line,
4678/// sides ride the add-only ConflictInfo fields.
4679pub fn conflicts(short: bool) -> CliResult<bool> {
4680 let Some(session) = Service::open()? else {
4681 return Ok(false);
4682 };
4683 let request = pb::ListConflictsRequest {
4684 repository: Some(session.reference.clone()),
4685 };
4686 let response = session.list_conflicts(request)?;
4687
4688 if short {
4689 for conflict in &response.conflicts {
4690 let line = conflict
4691 .line
4692 .map(|l| l.to_string())
4693 .unwrap_or_else(|| "-".into());
4694 println!(
4695 "{}:{}:{}",
4696 conflict.path,
4697 line,
4698 conflict.kind.as_deref().unwrap_or("-")
4699 );
4700 }
4701 return Ok(true);
4702 }
4703 if response.conflicts.is_empty() {
4704 print_success("No conflicts.");
4705 return Ok(true);
4706 }
4707 let file_word = if response.conflicts.len() == 1 {
4708 "file"
4709 } else {
4710 "files"
4711 };
4712 // Group by path for the render (the wire is per-record).
4713 let mut by_path: std::collections::BTreeMap<&str, Vec<&pb::ConflictInfo>> =
4714 std::collections::BTreeMap::new();
4715 for conflict in &response.conflicts {
4716 by_path.entry(&conflict.path).or_default().push(conflict);
4717 }
4718 println!(
4719 "{}",
4720 crate::output::warning(&format!("{} conflicted {}:", by_path.len(), file_word))
4721 );
4722 println!();
4723 for (path, records) in &by_path {
4724 println!("\t{path}");
4725 for record in records {
4726 let where_ = match record.line {
4727 Some(line) => format!("line {line}"),
4728 None => "unknown line".to_string(),
4729 };
4730 let kind = record.kind.as_deref().unwrap_or("conflict");
4731 if record.sides.is_empty() {
4732 println!("\t {kind} conflict at {where_}");
4733 } else {
4734 let sides = record
4735 .sides
4736 .iter()

Callers 1

runMethod · 0.85

Calls 9

openFunction · 0.85
print_successFunction · 0.85
print_hintFunction · 0.85
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