/** * 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; }
/** * 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'); }