public function execute(Git_Hook_PushDetails $push_details, $commit_sha1)
 {
     $rev_id = $push_details->getRepository()->getFullName() . '/' . $commit_sha1;
     $text = $this->git_exec->catFile($commit_sha1);
     $GLOBALS['group_id'] = $push_details->getRepository()->getProject()->getId();
     $this->reference_manager->extractCrossRef($text, $rev_id, Git::REFERENCE_NATURE, $push_details->getRepository()->getProject()->getId(), $push_details->getUser()->getId());
 }
 /**
  *
  * Behaviour extracted from official email hook prep_for_email() function
  *
  * @param GitRepository $repository
  * @param PFUser $user
  * @param type $oldrev
  * @param type $newrev
  * @param type $refname
  * @return Git_Hook_PushDetails
  */
 public function getPushDetails(GitRepository $repository, PFUser $user, $oldrev, $newrev, $refname)
 {
     $change_type = Git_Hook_PushDetails::ACTION_ERROR;
     $revision_list = array();
     $rev_type = '';
     try {
         if ($oldrev == self::FAKE_EMPTY_COMMIT) {
             $revision_list = $this->exec_repo->revListSinceStart($refname, $newrev);
             $change_type = Git_Hook_PushDetails::ACTION_CREATE;
         } elseif ($newrev == self::FAKE_EMPTY_COMMIT) {
             $change_type = Git_Hook_PushDetails::ACTION_DELETE;
         } else {
             $revision_list = $this->exec_repo->revList($oldrev, $newrev);
             $change_type = Git_Hook_PushDetails::ACTION_UPDATE;
         }
         if ($change_type == Git_Hook_PushDetails::ACTION_DELETE) {
             $rev_type = $this->exec_repo->getObjectType($oldrev);
         } else {
             $rev_type = $this->exec_repo->getObjectType($newrev);
         }
     } catch (Git_Command_Exception $exception) {
         $this->logger->error(__CLASS__ . " {$repository->getFullName()} {$refname} {$oldrev} {$newrev} " . $exception->getMessage());
     }
     return new Git_Hook_PushDetails($repository, $user, $refname, $change_type, $rev_type, $revision_list);
 }
 private function getReadmeFile($path, $node, $commit_sha1)
 {
     $files_list = $this->git_exec->lsTree($commit_sha1, $node);
     $markdown_files_list = array_values(preg_grep('/^readme\\.(markdown|mdown|mkdn|md|mkd|mdwn|mdtxt|mdtext|text)$/i', $files_list));
     if (isset($markdown_files_list[0])) {
         return $markdown_files_list[0];
     }
     return false;
 }
 private function getGitHttpBackendCommand()
 {
     $command = new Git_HTTP_CommandCentos5GitHttpBackend();
     if (Git_Exec::isGit19Installed()) {
         $command = new Git_HTTP_CommandSCL19GitHttpBackend();
     } elseif (is_file('/usr/libexec/git-core/git-http-backend')) {
         $command = new Git_HTTP_CommandCentos6GitHttpBackend();
     }
     return $command;
 }
 public function deleteMirror($old_hostname)
 {
     $git_modifications = $this->gitolite_conf_writer->deleteMirror($old_hostname);
     foreach ($git_modifications->toRemove() as $file) {
         $file_path = $this->getAdminPath() . '/' . $file;
         if (is_dir($file_path)) {
             if (!$this->gitExec->recursiveRm($file)) {
                 return false;
             }
         } elseif (is_file($file_path)) {
             if (!$this->gitExec->rm($file)) {
                 return false;
             }
         }
     }
     return true;
 }
 public function itMovesTheFilesInSymlinkedRepo()
 {
     $file_orig_path = $this->symlink_repo . '/file1';
     $file_dest_path = $this->symlink_repo . '/file with spaces';
     file_put_contents($file_orig_path, 'bla');
     $git_exec = new Git_Exec($this->symlink_repo);
     $git_exec->add($file_orig_path);
     $git_exec->commit('bla');
     $git_exec->mv($file_orig_path, $file_dest_path);
     $git_exec->commit('rename');
     $this->assertFalse($git_exec->isThereAnythingToCommit());
     $this->assertFalse(file_exists($file_orig_path));
     $this->assertEqual(file_get_contents($file_dest_path), 'bla');
 }
 /**
  * Rename a project
  * 
  * This method is intended to be called by a "codendiadm" owned process while general
  * rename process is owned by "root" (system-event) so there is dedicated script
  * (see bin/gl-rename-project.php) and more details in Git_Backend_Gitolite::glRenameProject.
  *
  * @param String $oldName The old name of the project
  * @param String $newName The new name of the project
  *
  * @return true if success, false otherwise
  */
 public function renameProject($oldName, $newName)
 {
     $ok = true;
     if (is_file('conf/projects/' . $oldName . '.conf')) {
         $ok = $this->gitExec->mv('conf/projects/' . $oldName . '.conf', 'conf/projects/' . $newName . '.conf');
         if ($ok) {
             //conf/projects/newone.conf
             $orig = file_get_contents('conf/projects/' . $newName . '.conf');
             $dest = preg_replace('`(^|\\n)repo ' . preg_quote($oldName) . '/`', '$1repo ' . $newName . '/', $orig);
             $dest = str_replace('@' . $oldName . '_project_', '@' . $newName . '_project_', $dest);
             file_put_contents('conf/projects/' . $newName . '.conf', $dest);
             $this->gitExec->add('conf/projects/' . $newName . '.conf');
             //conf/gitolite.conf
             $orig = file_get_contents($this->confFilePath);
             $dest = str_replace('include "projects/' . $oldName . '.conf"', 'include "projects/' . $newName . '.conf"', $orig);
             file_put_contents($this->confFilePath, $dest);
             $this->gitExec->add($this->confFilePath);
             //commit
             $ok = $this->gitExec->commit('Rename project ' . $oldName . ' to ' . $newName) && $this->gitExec->push();
         }
     }
     return $ok;
 }
 private function pushToServer()
 {
     $exec = new Git_Exec($this->dir);
     $exec->add($this->dir . '/project.config');
     $exec->add($this->dir . '/groups');
     $exec->commit('Updated project config and access rights');
     $exec->push('origin HEAD:refs/meta/config');
 }
Beispiel #9
0
 public function __construct($path, $remote_name)
 {
     parent::__construct($path);
     $this->remote_name = $remote_name;
 }