public function testCloneBranchNotBare() { //we can't use AbstractText::createFoobarRepository() //because it does not clone other branches than "master" //so we test it directly against remote repository $newDir = self::createTempDir(); $new = Admin::cloneBranchTo($newDir, self::REPOSITORY_URL, 'new-feature', false); self::registerDeletion($new); $head = $new->getHead(); $this->assertTrue($head instanceof Branch, "HEAD is a branch"); $this->assertEquals("new-feature", $head->getName(), "HEAD is branch new-feature"); }
/** * Init a git repository * * @param string $git Location of the git repo * @param string $branch branch to checkout * * @throws Exception\TestException * @return string local directory of the cloned repo */ private function initGit($git, $branch) { if (empty($branch)) { $branch = 'master'; } $this->output->writeln(sprintf("Checkout %s from git on branch %s.", $git, $branch)); $tmpdir = sys_get_temp_dir(); $uniq = $tmpdir . DIRECTORY_SEPARATOR . uniqid(); @mkdir($uniq); if (!file_exists($uniq)) { throw new TestException('Unable to create tmp directory'); } Admin::cloneBranchTo($uniq, $git, $branch, false); return $uniq; }