Returns the highest version category difference between two Release instances.

@param Release      $release1
@param Release|null $release2

@return string|null
423527
public static function getDifference(Release $release1, Release $release2 = null)
    {
        if ($release2 === null) {
            return self::MAJOR;
        }

        $version1 = explode('.', $release1->getVersion());
        $version2 = explode('.', $release2->getVersion());
        if (isset($version1[0]) === false || isset($version2[0]) === false || $version1[0] != $version2[0]) {
            return self::MAJOR;
        } elseif (isset($version1[1]) === false || isset($version2[1]) === false || $version1[1] != $version2[1]) {
            return self::MINOR;
        } elseif (isset($version1[2]) === false || isset($version2[2]) === false || $version1[2] != $version2[2]) {
            return self::PATCH;
        }
    }
767422
public String getLastRelease(final Collection<String> versions) {
        final List<Version> sorted = versions.stream()
                .filter(Version::isValid)               // filter invalid input values
                .map(Version::make)
                .filter(Optional::isPresent)
                .map(Optional::get)
                .filter(Version::isRelease)
                .sorted((v1, v2) -> {
                    try {
                        return v1.compare(v2);
                    } catch (IncomparableException e) {
                        return 0;
                    }
                })
                .collect(Collectors.toList());

        if(sorted.isEmpty()) {
            if(LOG.isWarnEnabled()) {
                LOG.warn(String.format("Cannot obtain last release from collection %s", versions.toString()));
            }
            return null;
        }

        return sorted.get(sorted.size() - 1).toString();
    }
1372263
private function comparePhingVersion($version)
    {
        $current = strtolower(self::getPhingVersion());
        $current = trim(str_replace('phing', '', $current));

        // make sure that version checks are not applied to trunk
        if ('dev' === $current) {
            return 1;
        }

        if (-1 == version_compare($current, $version)) {
            throw new BuildException(
                sprintf('Incompatible Phing version (%s). Version "%s" required.', $current, $version)
            );
        }
    }
189899
protected function createLink(Release $release)
	{
		$line = '';

		$link = $release->getLink();

		if ($link !== null)
		{
			$linkName = $release->getLinkName();
			$name = $release->getName();

			$reference = ($linkName === null) ? $name : $linkName;

			$line = "[$reference] $link\n";
		}

		return $line;
	}
253166
function semanticVersionComparator (v1, v2) {
  const [major1, minor1, patch1] = v1.split('.').map(Number)
  const [major2, minor2, patch2] = v2.split('.').map(Number)
  if (major1 > major2) {
    return 1
  } else if (major1 === major2) {
    if (minor1 > minor2) {
      return 1
    } else if (minor1 === minor2) {
      if (patch1 > patch2) {
        return 1
      } else if (patch1 === patch2) {
        return 0
      } else {
        return -1
      }
    } else {
      return -1
    }
  } else {
    return -1
  }
}
204045
protected function renderRelease(Release $release)
	{
		$date = null;

		if ($release->getDate() !== null)
		{
			$date = $release->getDate()->format('Y-m-d');
		}

		return [
			'name' => $release->getName(),
			'link' => $release->getLink(),
			'linkName' => $release->getLinkName(),
			'date' => $date,
			'changes' => $release->getAllChanges(),
		];
	}
861566
public function hasVersionMigrated(Version $version)
    {
        $this->createMigrationCollection();

        $record = $this->getCollection()->findOne(['v' => $version->getVersion()]);

        return null !== $record;
    }
1249628
public function compare($key1 , $key2) {
        $record1 = $this->contents[$key1];
        $record2 = $this->contents[$key2];

        // If a content's fieldtype is compulsory in the database than it would have priority than any other noncompulsory content.
        if ( ($record1->required && $record2->required) || (!$record1->required && !$record2->required)) {
            if ($record1->priority === $record2->priority) {
                return $key1 < $key2 ? 1 : -1;
            }

            return $record1->priority < $record2->priority ? -1 : 1;

        } else if ($record1->required && !$record2->required) {
            return 1;
        } else {
            return -1;
        }

    }
817603
def compare_version(version1, version2):
    
    def normalize(v):
        return [int(x) for x in re.sub(r'(\.0+)*$','', v).split(".")]
    return (normalize(version1) > normalize(version2))-(normalize(version1) < normalize(version2))
954255
public static int compareVersions(String v1, String v2) {
		String[] v1a = v1.split("\\.");
		String[] v2a = v2.split("\\.");
		Integer v1M = Integer.parseInt(v1a[0]);
		Integer v2M = Integer.parseInt(v2a[0]);
		if (v1M < v2M) {
			return -1;
		} else if (v1M > v2M) {
			return 1;
		} else {
			Integer v1min = Integer.parseInt(v1a[1]);
			Integer v2min = Integer.parseInt(v2a[1]);
			if (v1min < v2min) {
				return -1;
			} else if (v1min > v2min) {
				return 1;
			} else {
				return 0;
			}
		}
	}
717744
private function ascSortStrategy($declaration1, $declaration2)
    {
        if ($declaration1->priority === $declaration2->priority) {
            return $declaration1->sequence < $declaration2->sequence ? 1 : -1;
        }

        return $declaration1->priority > $declaration2->priority ? 1 : -1;
    }
556622
public function version($versionId, $reset = false)
    {
        $versions = $this->versions($reset);
        if (empty($versions[$versionId])) {
            return null;
        }

        return $versions[$versionId];
    }
279211
private function _mergeDependencyVersions(array $array1, array $array2) {
        foreach ($array2 as $package => $version) {
            if (!isset($array1[$package])) {
                $array1[$package] = $version;
            } else {
                if ($array1[$package] != $version) {
                    $array1[$package] .= " ".$version;
                }
            }
        }
        return $array1;
    }
1349226
public static int compareVersions(String v1, String v2) {
		String s1 = normalisedVersion(v1);
		String s2 = normalisedVersion(v2);
		return s1 != null ? (s2 != null ? s1.compareTo(s2) : 1)
				: (s2 != null ? -1 : 0);
	}
8451
static function version( $withRelease = true, $asAlias = false, $withState = true )
    {
        if ( $asAlias )
        {
            $versionText = eZPublishSDK::alias();
            if ( $withState && eZPublishSDK::state() )
                $versionText .= "-" . eZPublishSDK::state();
        }
        else
        {
            $versionText = eZPublishSDK::majorVersion() . '.' . eZPublishSDK::minorVersion();
//            $development = eZPublishSDK::developmentVersion();
//            if ( $development !== false )
//                $versionText .= '.' . $development;
            if ( $withRelease )
                $versionText .= "." . eZPublishSDK::release();
            if ( $withState )
                $versionText .= eZPublishSDK::state();
        }
        return $versionText;
    }
507007
def equivalent_release_for_product(self, product):
        
        releases = self._default_manager.filter(
            version__startswith=self.major_version() + '.',
            channel=self.channel, product=product).order_by('-version')
        if not getattr(settings, 'DEV', False):
            releases = releases.filter(is_public=True)
        if releases:
            return sorted(
                sorted(releases, reverse=True,
                       key=lambda r: len(r.version.split('.'))),
                reverse=True, key=lambda r: r.version.split('.')[1])[0]
1354714
private static function preReleaseGreaterThan(PreRelease $v1, PreRelease $v2)
    {
        // Pre-releases can be denoted as versionable (X.Y.Z) or greek (alpha.5)
        // We let versionable take precedence
        if (!self::versionableEquals($v1, $v2)) {
            // If v1 is bigger on the versionable level, it's bigger.
            return self::versionableGreaterThan($v1, $v2);
        }

        // "Greek" part is "bigger" for v1
        if ($v1->getGreek() !== $v2->getGreek()) {
            return self::greekLargerThan($v1->getGreek(), $v2->getGreek());
        }

        // Release number for v1 is bigger than v2's
        if ($v1->getReleaseNumber() > $v2->getReleaseNumber()) {
            return true;
        }

        return false;
    }