예제 #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');
 }
 /**
  * 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;
     $git_modifications = $this->gitolite_conf_writer->renameProject($oldName, $newName);
     foreach ($git_modifications->toAdd() as $file) {
         $ok = $ok && $this->gitExec->add($file);
     }
     foreach ($git_modifications->toMove() as $old_file => $new_file) {
         $ok = $ok && $this->gitExec->mv($old_file, $new_file);
     }
     if ($ok) {
         $ok = $this->gitExec->commit('Rename project ' . $oldName . ' to ' . $newName) && $this->gitExec->push();
     }
     return $ok;
 }
예제 #3
0
 /**
  * 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;
 }
예제 #4
0
 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');
 }