Validate origin-local invariants without changing parent order.
(&self)
| 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. |
no test coverage detected