Esempio n. 1
0
 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');
 }
 public function updateMirror($mirror_id, $old_hostname)
 {
     $git_modifications = $this->gitolite_conf_writer->updateMirror($mirror_id, $old_hostname);
     foreach ($git_modifications->toAdd() as $file) {
         if (!$this->gitExec->add($file)) {
             return false;
         }
     }
     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;
 }
 /**
  * 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');
 }