/** * Returns list of version in repository. * * @return array (version => hash) */ private function getVersions() { $versions = array(); $tags = $this->repository->getTags(); $branches = $this->repository->getBranches(); $util = new Utils\VersionParser(); // TODO: use dependency injection foreach ($tags as $tag => $hash) { $version = $util->parseTag($tag); if (!$version) { continue; } $versions[$version] = $tag; } foreach ($branches as $branch => $hash) { $version = $util->parseBranch($branch); $versions[$version] = $branch; } return $versions; }
public function isVersionValid($versionString) { return (bool) $this->versionParser->parseTag($versionString); }
/** * Creates new addon version from values and adds it to addon. * * @param \NetteAddons\Model\Addon * @param array * @param \Nette\Security\IIdentity * @param \NetteAddons\Model\Utils\VersionParser * @return \NetteAddons\Model\AddonVersion * @throws \NetteAddons\InvalidArgumentException * @throws \NetteAddons\IOException */ public function addVersionFromValues(Addon $addon, $values, IIdentity $owner, VersionParser $versionParser) { if (!$values->license) { throw new \NetteAddons\InvalidArgumentException("License is mandatory."); } if (!$values->version) { throw new \NetteAddons\InvalidArgumentException("Version is mandatory."); } $version = new AddonVersion(); $version->addon = $addon; $version->version = $versionParser->parseTag($values->version); $version->license = is_array($values->license) ? implode(', ', $values->license) : $values->license; $version->distType = 'zip'; $version->distUrl = $values->archiveLink; $version->composerJson = Composer::createComposerJson($version); $version->composerJson->authors = array((object) array('name' => $owner->realname, 'email' => $owner->email)); $addon->versions[] = $version; return $version; }