public function testPreleaseCompare() { // 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0 $versions = ['1.0.0-0', '1.0.0-1', '1.0.0-2', '1.0.0-11', '1.0.0-alpha', '1.0.0-alpha.1', '1.0.0-alpha.beta', '1.0.0-beta', '1.0.0-beta.2', '1.0.0-beta.11', '1.0.0-rc.1', '1.0.0', '1.1.0', '2.1.0']; foreach ($versions as $ia => $a) { $aVersion = new \Gini\Version($a); foreach ($versions as $ib => $b) { if ($ia == $ib) { $this->assertEquals($aVersion->compare($b), 0, "expecting {$a} = {$b}"); } elseif ($ia > $ib) { $this->assertEquals($aVersion->compare($b), 1, "expecting {$a} > {$b}"); } else { $this->assertEquals($aVersion->compare($b), -1, "expecting {$a} < {$b}"); } } } }
public function actionVersion($argv) { $info = \Gini\Core::moduleInfo(APP_ID); $version = $argv[0]; if ($version) { // set current version $v = new \Gini\Version($version); $v->compare($info->version) > 0 or die("A newer version (>{$info->version}) is required!\n"); $info->version = $version; \Gini\Core::saveModuleInfo($info); // commit it if it is a git repo if (is_dir(APP_PATH . '/.git')) { $WORK_TREE = escapeshellarg(APP_PATH); $GIT_DIR = escapeshellarg(APP_PATH . '/.git'); $GIT_MSG = escapeshellarg("Bumped version to {$version}"); $command = "git --git-dir={$GIT_DIR} --work-tree={$WORK_TREE} commit -m {$GIT_MSG} gini.json && git --git-dir={$GIT_DIR} tag {$version}"; passthru($command); return; } } echo "{$info->name} ({$info->id}/{$info->version})\n"; }