public function testCreateClone() { $dirname = $this->generateTmpDir(); $instance = new VersionControl_Git($dirname); $instance->createClone('git://gist.github.com/265855.git'); $this->assertTrue(is_dir($dirname . DIRECTORY_SEPARATOR . '265855')); $this->removeDirectory($dirname); $dirname = $this->generateTmpDir(); $instance = new VersionControl_Git($dirname); $instance->createClone('git://gist.github.com/265855.git', true); if (version_compare('1.6.0-rc1', $instance->getGitVersion(), '>=')) { // see: http://git.kernel.org/?p=git/git.git;a=commit;h=6612f87 $this->assertTrue(is_file($dirname . DIRECTORY_SEPARATOR . '265855' . DIRECTORY_SEPARATOR . 'HEAD')); } else { $this->assertTrue(is_file($dirname . DIRECTORY_SEPARATOR . '265855.git' . DIRECTORY_SEPARATOR . 'HEAD')); } $this->removeDirectory($dirname); $dirname = $this->generateTmpDir(); $instance = new VersionControl_Git($dirname); $instance->createClone('git://gist.github.com/265855.git', true, $dirname . DIRECTORY_SEPARATOR . 'MY_WORKING_COPY'); $this->assertTrue(is_dir($dirname . DIRECTORY_SEPARATOR . 'MY_WORKING_COPY')); $this->assertTrue(realpath($instance->getDirectory()) === realpath($dirname . DIRECTORY_SEPARATOR . 'MY_WORKING_COPY')); $this->removeDirectory($dirname); $dirname = $this->generateTmpDir(); $instance = new VersionControl_Git($dirname); $instance->createClone('git://gist.github.com/265855.git', false, $dirname); $this->assertTrue(is_file($dirname . DIRECTORY_SEPARATOR . 'patch_for_pecl_runkit.diff')); $this->removeDirectory($dirname); }
<?php require_once '/php/VersionControl/Git.php'; // Specify a directory $git = new VersionControl_Git('../../../../public_html/sitionuevo/test'); // create new repository $git->createClone('git@github.com:aopazo/web.git'); $commits = $git->getCommits(); // exec("git pull git@github.com:aopazo/web.git master", $output, $return_var); // exec("ls", $output); ?> <html> <body> Commits: <?php echo $commits; ?> <br /> Script ejecutado. </body> </html>
protected function importFromGit($gitUrl, $gitCommit) { $filesystem = new sfFilesystem(); require_once 'VersionControl/Git.php'; $dir = sfConfig::get('sf_cache_dir') . '/git-' . md5($gitUrl . $gitCommit); $filesystem->mkdirs($dir); $git = new VersionControl_Git(sfConfig::get('sf_cache_dir')); $git->createClone($gitUrl, false, $dir); $filesystem->chmod($dir, 0777); $git->checkout($gitCommit); return $dir; }