#!/usr/bin/php <?php if ('cli' != php_sapi_name()) { die; } ini_set('memory_limit', '128M'); if (!defined('DOKU_INC')) { define('DOKU_INC', realpath(dirname(__FILE__) . '/../') . '/'); } define('NOSESSION', 1); require_once DOKU_INC . 'inc/init.php'; $GitToolCLI = new GitToolCLI(); array_shift($argv); $command = array_shift($argv); switch ($command) { case '': case 'help': $GitToolCLI->cmd_help(); break; case 'clone': $GitToolCLI->cmd_clone($argv); break; case 'install': $GitToolCLI->cmd_install($argv); break; case 'repo': case 'repos': $GitToolCLI->cmd_repos(); break; default: $GitToolCLI->cmd_git($command, $argv);
$repourl = $ext->getSourcerepoURL(); if (!$repourl) { return false; } // match github repos if (preg_match('/github\\.com\\/([^\\/]+)\\/([^\\/]+)/i', $repourl, $m)) { $user = $m[1]; $repo = $m[2]; return 'https://github.com/' . $user . '/' . $repo . '.git'; } // match gitorious repos if (preg_match('/gitorious.org\\/([^\\/]+)\\/([^\\/]+)?/i', $repourl, $m)) { $user = $m[1]; $repo = $m[2]; if (!$repo) { $repo = $user; } return 'https://git.gitorious.org/' . $user . '/' . $repo . '.git'; } // match bitbucket repos - most people seem to use mercurial there though if (preg_match('/bitbucket\\.org\\/([^\\/]+)\\/([^\\/]+)/i', $repourl, $m)) { $user = $m[1]; $repo = $m[2]; return 'https://bitbucket.org/' . $user . '/' . $repo . '.git'; } return false; } } // Main $cli = new GitToolCLI(); $cli->run();