protected function presetSemver($source, $target)
{
if (0 === preg_match(self::VERSION_REGEX, $source, $sourceMatch) || 0 === preg_match(self::VERSION_REGEX, $target, $targetMatch)) {
return;
// cannot validate branches, abstain decision
}
if ((int) $sourceMatch['major'] > (int) $targetMatch['major']) {
throw new MergeWorkflowException([sprintf('Workflow violation: Cannot merge "%s" into "%s".', $source, $target), sprintf('Semver: major version of source "%s" is higher then major version of target "%s".', $source, $target)]);
}
if ('x' === $sourceMatch['minor'] || 'x' === $targetMatch['minor']) {
return true;
// allow merge
}
if ((int) $sourceMatch['minor'] > (int) $targetMatch['minor']) {
throw new MergeWorkflowException([sprintf('Workflow violation: Cannot merge "%s" into "%s".', $source, $target), sprintf('Semver: minor version of source "%s" is higher then minor version of target "%s".', $source, $target)]);
}
}