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

Method validate

atomic-core/src/change/classification.rs:125–166  ·  view source on GitHub ↗

Validate origin-local invariants without changing parent order.

(&self)

Source from the content-addressed store, hash-verified

123
124 /// Validate origin-local invariants without changing parent order.
125 pub fn validate(&self) -> Result<(), ChangeValidationError> {
126 match self {
127 Self::Native => Ok(()),
128 Self::GitSynthesized {
129 commit,
130 parents,
131 derivation,
132 } => {
133 validate_git_algorithms("GitSynthesized", commit, parents)?;
134 let actual = parents.len();
135 let valid = match derivation {
136 GitDerivation::Root => actual == 0,
137 GitDerivation::FirstParent => actual == 1,
138 GitDerivation::MultiParent => actual >= 2,
139 GitDerivation::Squash
140 | GitDerivation::EmptyCommit
141 | GitDerivation::RewriteCandidate => true,
142 };
143 if !valid {
144 return Err(ChangeValidationError::InvalidDerivationParentCount {
145 derivation: *derivation,
146 actual,
147 });
148 }
149 Ok(())
150 }
151 Self::GitResolution {
152 merge_commit,
153 parents,
154 } => {
155 validate_git_algorithms("GitResolution", merge_commit, parents)?;
156 if parents.len() < 2 {
157 return Err(
158 ChangeValidationError::GitResolutionRequiresMultipleParents {
159 actual: parents.len(),
160 },
161 );
162 }
163 Ok(())
164 }
165 }
166 }
167}
168
169/// Canonical roots whose verified closures are causally known by a change.

Callers 2

git_synthesizedMethod · 0.45
git_resolutionMethod · 0.45

Calls 3

validate_git_algorithmsFunction · 0.85
lenMethod · 0.45

Tested by

no test coverage detected