/** * Setup GIT Repos from Stash * * Lists all repos from remote project and downloaded them, skipping devtools * * @param string $directory Directory to work with * @param bool $force True or False on whether to rm -Rf and then recreate the repo * @return array */ function setupDevRepos($directory, $force = false, $mode = 'ssh', $branch = 'master', $project_key = 'freepbx') { $skipr = array('devtools', 'moh_sounds', 'versionupgrade', 'fw_langpacks', 'custom-freepbx-modules', 'sipstation_module'); $o = $this->stash->getAllRepos($project_key); if ($mode == 'http' && version_compare(Git::version(), '1.7.9', '<')) { freepbx::out("HTTP Mode is only supported with GIT 1.7.9 or Higher"); die; } elseif ($mode == 'http') { Git::enable_credential_cache(); } foreach ($o['values'] as $repos) { $dir = $directory . '/' . $repos['name']; if (in_array($repos['name'], $skipr)) { continue; } freepbx::outn("Cloning " . $repos['name'] . " into " . $dir . "..."); if (file_exists($dir) && $force) { freepbx::out($dir . " Already Exists but force is enabled so deleting and restoring"); exec('rm -Rf ' . $dir); } elseif (file_exists($dir)) { freepbx::out($dir . " Already Exists, Skipping (use --force to force)"); continue; } $uri = $mode == 'http' ? $repos['cloneUrl'] : $repos['cloneSSH']; $repo = Git::create($dir, $uri); $repo->add_merge_driver(); freepbx::out("Done"); $obranch = $branch; while ($branch) { try { freepbx::outn("\tChecking you out into the " . $branch . " branch..."); $repo->checkout($branch); freepbx::out("Done"); break; } catch (Exception $e) { freepbx::out("Doesnt Exist!"); $branch = $this->getLowerBranch($branch); if ($branch === false) { try { freepbx::outn("\tChecking you out into the master branch..."); $repo->checkout('master'); freepbx::out("Done"); } catch (Exception $e) { //TODO: error? } } } } $branch = $obranch; freepbx::out(" "); } }
if (!file_exists($directory . '/' . $options['m'])) { if (empty($vars['username'])) { $username = freepbx::getInput("FreePBX Username"); } else { $username = $vars['username']; } if (empty($vars['password'])) { $password = freepbx::getPassword("FreePBX Password", true); } else { $password = $vars['password']; } if ($mode == 'http' && version_compare(Git::version(), '1.7.9', '<')) { freepbx::out("HTTP Mode is only supported with GIT 1.7.9 or Higher"); die; } elseif ($mode == 'http') { Git::enable_credential_cache(); } if (isset($options['r'])) { $stash->project_key = $project; $repo = $stash->getRepo($options['r']); if ($repo === false) { freepbx::out("[ERROR] Unable to find " . $options['m']); exit(0); } } else { $stash = new Stash($username, $password); foreach ($projects as $project => $description) { $repo = $stash->getRepo($options['m'], $project); if ($repo === false) { freepbx::out("[WARN] " . $options['m'] . " is NOT in the " . $description); } else {