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

Method validate

atomic-repository/src/repository/conflict_object.rs:371–395  ·  view source on GitHub ↗

Structural self-check: every entry must name at least one side or claimant, and every file must have entries.

(&self)

Source from the content-addressed store, hash-verified

369 /// Structural self-check: every entry must name at least one side or
370 /// claimant, and every file must have entries.
371 pub fn validate(&self) -> Result<(), ConflictObjectError> {
372 for file in &self.files {
373 if file.entries.is_empty() {
374 return Err(ConflictObjectError::NoSides {
375 identity: format!("path {}", String::from_utf8_lossy(&file.path)),
376 });
377 }
378 for entry in &file.entries {
379 let identity = format!(
380 "{}:{}@{}",
381 entry.kind.as_str(),
382 String::from_utf8_lossy(&file.path),
383 entry.line.unwrap_or(0)
384 );
385 if entry.sides.is_empty() && entry.claimants.is_empty() {
386 return Err(ConflictObjectError::NoSides { identity });
387 }
388 if !entry.claimants.is_empty() && entry.sides.is_empty() {
389 // A name conflict legitimately records claimants only.
390 continue;
391 }
392 }
393 }
394 Ok(())
395 }
396}
397
398// ── Capture: graph → conflict object ─────────────────────────────────────

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected