Get the latest version that has been published in a certain repository.
Example: 2.6.5 or v2.6.5.

@param string $prepend Prepend a string to the latest version
@param string $append  Append a string to the latest version

@return string
515861
public function getVersionAvailable($prepend = '', $append = '') : string
    {
        $version = '';
        if ($this->versionFileExists()) {
            $version = $this->getVersionFile();
        } else {
            $releaseCollection = $this->getPackageReleases();
            if ($releaseCollection->isEmpty()) {
                throw new \Exception('Retrieved version list is empty.');
            }
            $version = $releaseCollection->first()->name;
        }

        return $version;
    }
620
public function getPreviousVersion($from)
    {
        $lastTimestamp = 0;
        foreach (array_keys($this->versions) as $timestamp) {
            if ($timestamp == $from) {
                return $lastTimestamp;
            }
            $lastTimestamp = $timestamp;
        }

        return 0;
    }
42845
private function get_assets_version( $append_version, $q = 'v' ) {
		if ( ! $append_version ) {
			return '';
		}
		$append = trim( $this->apply_filters( 'assets_version' ) );
		if ( $append !== '' ) {
			if ( $q ) {
				return '?' . $q . '=' . $append;
			}

			return '?' . $append;
		}

		return '';
	}
348764
public function VersionsForm()
    {
        $id = $this->currentPageID();
        $page = $this->getRecord($id);
        $versionsHtml = '';

        $action = $this->getRequest()->param('Action');
        $versionID = $this->getRequest()->param('VersionID');
        $otherVersionID = $this->getRequest()->param('OtherVersionID');

        $showUnpublishedChecked = 0;
        $compareModeChecked = ($action == "compare");

        if ($page) {
            $versions = $page->allVersions();
            $versionID = (!$versionID) ? $page->Version : $versionID;

            if ($versions) {
                foreach ($versions as $k => $version) {
                    $active = false;

                    if ($version->Version == $versionID || $version->Version == $otherVersionID) {
                        $active = true;

                        if (!$version->WasPublished) {
                            $showUnpublishedChecked = 1;
                        }
                    }

                    $version->Active = ($active);
                }
            }

            $vd = new ViewableData();

            $versionsHtml = $vd->customise(array(
                'Versions' => $versions
            ))->renderWith($this->getTemplatesWithSuffix('_versions'));
        }

        $fields = new FieldList(
            new CheckboxField(
                'ShowUnpublished',
                _t('SilverStripe\\CMS\\Controllers\\CMSPageHistoryController.SHOWUNPUBLISHED', 'Show unpublished versions'),
                $showUnpublishedChecked
            ),
            new CheckboxField(
                'CompareMode',
                _t('SilverStripe\\CMS\\Controllers\\CMSPageHistoryController.COMPAREMODE', 'Compare mode (select two)'),
                $compareModeChecked
            ),
            new LiteralField('VersionsHtml', $versionsHtml),
            $hiddenID = new HiddenField('ID', false, "")
        );

        $form = Form::create(
            $this,
            'VersionsForm',
            $fields,
            new FieldList()
        )->setHTMLID('Form_VersionsForm');
        $form->loadDataFrom($this->getRequest()->requestVars());
        $hiddenID->setValue($id);
        $form->unsetValidator();

        $form
            ->addExtraClass('cms-versions-form') // placeholder, necessary for $.metadata() to work
            ->setAttribute('data-link-tmpl-compare', Controller::join_links($this->Link('compare'), '%s', '%s', '%s'))
            ->setAttribute('data-link-tmpl-show', Controller::join_links($this->Link('show'), '%s', '%s'));

        return $form;
    }
1103136
protected function getVersion()
    {
        static $version;
        if (!$version) {
            $version = false;
            $string = $this->execute(['--version'], false);
            if ($string && preg_match('/(^| )([0-9]+[^ ]*)/', $string, $matches)) {
                $version = $matches[2];
            }
        }

        return $version;
    }
776278
public function getUpdatedAt() : ?string 
    {
        if ( ! $this->hasUpdatedAt()) {
            $this->setUpdatedAt($this->getDefaultUpdatedAt());
        }
        return $this->updatedAt;
    }
706319
protected function getVersionsToCompare(): string
    {
        return escapeshellarg($this->from) . (empty($this->to) ? '' : ' ' . escapeshellarg($this->to));
    }
529642
public function replaceInFile($old, $new, $append = 0)
    {
        $contents = $this->previous;
        $replaceWith = preg_replace("~$old\n?~", "$new\n", $contents);

        file_put_contents($this->getPath(), $replaceWith, $append);

        return $this;
    }
192754
private static function file_get_version($package) {
		if (file_exists(Config::$migration_directory . '/db_version')) {
			$version_file = trim(file_get_contents(Config::$migration_directory . '/db_version'));
			$version = json_decode($version_file, true);
		} else {
			$version = null;
		}

		if ($version === null and file_exists(Config::$migration_directory . '/db_version')) {
			// This is an old db_version file, let's update it
			$version = [
				'project' => $version_file
			];
			file_put_contents(Config::$migration_directory . '/db_version', json_encode($version));
		}

		if (empty($version[$package])) {
			return null;
		}

		return \DateTime::createFromFormat('Ymd His', $version[$package]);
	}
536025
protected function getRelativeFile($base = '', $prepend = true)
    {
        // find file path w/o extension
        $inputFile = $this->getInputFileWithoutExt();
        $inputRoot = $this->getView()->getInputRootDir();

        // Normalize direcotry separators so comparison works
        $trans = array(
            '/' => DIRECTORY_SEPARATOR,
            '\\' => DIRECTORY_SEPARATOR
        );
        $inputFile = strtr($inputFile, $trans);
        $inputRoot = strtr($inputRoot, $trans);

        // Remove the input root from the input filename
        $inputFile = str_replace($inputRoot, '', $inputFile);

        // find relative path, wrt to output root dir
        if ($base) {
            $pos = strpos($inputFile, $base);
            if ($pos !== false) {
                $inputFile = substr($inputFile, $pos + ($prepend ? 0 : 1 + strlen($base)));
            }
        }

        return $inputFile;
    }
720261
public function getOneVersion($versionNumber, $con = null)
    {
        return ChildDealerAdminVersionQuery::create()
            ->filterByDealerAdmin($this)
            ->filterByVersion($versionNumber)
            ->findOne($con);
    }
1038647
function Version()
	{
		$ver = (is_null($this) ? XDB_VERSION : $this->version);
		$str = sprintf("%s/%d.%d", XDB_TAGNAME, ($ver >> 5), ($ver & 0x1f));
		if (!is_null($this)) $str .= " <base={$this->hash_base}, prime={$this->hash_prime}>";
		return $str;
	}
1371743
public function getVersion()
    {
        return new Version(
            $this->major,
            $this->minor,
            $this->patch,
            $this->preRelease,
            $this->build
        );
    }
1056127
public static final function prepend(array $Source, array $Prepend): array {
		return array_merge($Prepend, self::only($Source, array_filter(array_keys($Source), function($value) use ($Prepend){
			return is_int($value) || !array_key_exists($value, $Prepend); })));
	}
96950
protected function writeVersionInfo()
    {
        if (PHP_SAPI !== 'cli') {
            return;
        }

        try {
            $client = $this->config->getChecker();
            if (!$client->isLatest()) {
                $this->output->writeln(\sprintf('New version is available (current: %s, latest: %s)', self::VERSION, $client->getLatest()));
            }
        } catch (\InvalidArgumentException $e) {
            $this->output->writeln($e->getMessage());
        }
    }
704596
protected function getCurrentVersion()
    {
        $version = $this->getBinary()->run('--version');
        $version = str_replace('v', null, $version);

        return $version;
    }
1026089
public function getUpdates()
    {
        if (!$this->loadRepositories()) {
            return Repository::STATUS_NO_REPOSITORIES;
        }

        $modules = $this->getModulesFromRepository();

        // Is a higher version of an already installed package available?
        foreach ($modules as $key => $module) {
            $version = $this->packageService->getVersion($module->name);

            if (!$version) {
                // Not installed at all.
                unset($modules[$key]);
            } elseif (version_compare($version, $module->version, '<')) {
                // Older version installed.
                $modules[$key]->versionInstalled = $version;
            } else {
                unset($modules[$key]);
            }
        }

        return $modules;
    }