Пример #1
0
 public static function setUpBeforeClass()
 {
     if (getenv('TMP')) {
         self::$tmpdir = getenv('TMP');
     } elseif (getenv('TMPDIR')) {
         self::$tmpdir = getenv('TMPDIR');
     } else {
         self::$tmpdir = '/tmp';
     }
     self::$tmpdir .= '/gitlist_' . md5(time() . mt_rand()) . '/';
     $fs = new Filesystem();
     $fs->mkdir(self::$tmpdir);
     if (!is_writable(self::$tmpdir)) {
         $this->markTestSkipped('There are no write permissions in order to create test repositories.');
     }
     $options['path'] = getenv('GIT_CLIENT') ?: '/usr/bin/git';
     $options['hidden'] = array(self::$tmpdir . '/hiddenrepo');
     $git = new Client($options);
     // GitTest repository fixture
     $git->createRepository(self::$tmpdir . 'GitTest');
     $repository = $git->getRepository(self::$tmpdir . 'GitTest');
     file_put_contents(self::$tmpdir . 'GitTest/README.md', "## GitTest\nGitTest is a *test* repository!");
     file_put_contents(self::$tmpdir . 'GitTest/test.php', "<?php\necho 'Hello World'; // This is a test");
     $repository->setConfig('user.name', 'Luke Skywalker');
     $repository->setConfig('user.email', '*****@*****.**');
     $repository->addAll();
     $repository->commit("Initial commit");
     $repository->createBranch('issue12');
     $repository->createBranch('issue42');
     // foobar repository fixture
     $git->createRepository(self::$tmpdir . 'foobar');
     $repository = $git->getRepository(self::$tmpdir . '/foobar');
     file_put_contents(self::$tmpdir . 'foobar/bar.json', "{\n\"name\": \"foobar\"\n}");
     file_put_contents(self::$tmpdir . 'foobar/.git/description', 'This is a test repo!');
     $fs->mkdir(self::$tmpdir . 'foobar/myfolder');
     $fs->mkdir(self::$tmpdir . 'foobar/testfolder');
     file_put_contents(self::$tmpdir . 'foobar/myfolder/mytest.php', "<?php\necho 'Hello World'; // This is my test");
     file_put_contents(self::$tmpdir . 'foobar/testfolder/test.php', "<?php\necho 'Hello World'; // This is a test");
     $repository->setConfig('user.name', 'Luke Skywalker');
     $repository->setConfig('user.email', '*****@*****.**');
     $repository->addAll();
     $repository->commit("First commit");
 }
Пример #2
0
 public function indexAction()
 {
     if ($this->getRequest()->isPost()) {
         $repositorio = $this->getRequest()->getPost('repositorio');
         $usuario = $this->getRequest()->getPost('usuario');
         $repo = new Client();
         $repo->createRepository("/home/git/{$usuario}/{$repositorio}.git", true);
     }
     return new ViewModel();
 }