/** * Initializes the tag: check if tag must be skipped and validate the tag. * * @param VcsDriverInterface $driver * @param string $packageName * @param string $tag * @param string $identifier */ protected function initTag(VcsDriverInterface $driver, $packageName, $tag, $identifier) { if (null !== $this->filter && $this->filter->skip($this->assetType, $packageName, $tag)) { return; } if (!($parsedTag = Validator::validateTag($tag, $this->assetType, $this->versionParser))) { if ($this->verbose) { $this->io->write('<warning>Skipped tag ' . $tag . ', invalid tag name</warning>'); } return; } $this->initTagAddPackage($driver, $packageName, $tag, $identifier, $parsedTag); }
/** * @param $type * * @dataProvider getAssetTypes */ public function testInvalidTag($type) { $assetType = Assets::createType($type); $this->assertFalse(Validator::validateTag('version', $assetType)); }
/** * Convert the dependency version. * * @param AssetTypeInterface $assetType The asset type * @param string $dependency The dependency * @param string $version The version * * @return string[] The new dependency and the new version */ public static function convertDependencyVersion(AssetTypeInterface $assetType, $dependency, $version) { $version = str_replace('#', '', $version); $version = empty($version) ? '*' : $version; $version = trim($version); $searchVersion = str_replace(array(' ', '<', '>', '=', '^', '~'), '', $version); // sha version or branch verison if (preg_match('{^[0-9a-f]{40}$}', $version)) { $version = 'dev-default#' . $version; } elseif ('*' !== $version && !Validator::validateTag($searchVersion, $assetType) && !static::depIsRange($version)) { $oldVersion = $version; $version = 'dev-' . $assetType->getVersionConverter()->convertVersion($version); if (!Validator::validateBranch($oldVersion)) { $version .= ' || ' . $oldVersion; } } return array($dependency, $version); }