public function triggerDelete($repository_path) { $all_mirrors = $this->data_mapper->fetchAll(); foreach ($all_mirrors as $mirror) { $this->generator->removeRepositoryFromManifestFile($mirror, $repository_path); } }
public function updateRepositoryMirrors(GitRepository $repository, array $mirror_ids) { if ($this->mirror_data_mapper->doesAllSelectedMirrorIdsExist($mirror_ids) && $this->mirror_data_mapper->unmirrorRepository($repository->getId()) && $this->mirror_data_mapper->mirrorRepositoryTo($repository->getId(), $mirror_ids)) { $this->history_dao->groupAddHistory("git_repo_mirroring_update", $repository->getName(), $repository->getProjectId()); return true; } return false; }
public function revokeProjectsFromMirror(Git_Mirror_Mirror $mirror, array $project_ids) { $this->restricted_mirror_dao->revokeProjectsFromResource($mirror->id, $project_ids); $repositories = $this->mirror_data_mapper->fetchAllProjectRepositoriesForMirror($mirror, $project_ids); foreach ($repositories as $repository) { $this->mirror_data_mapper->unmirrorRepository($repository->getId()); $this->git_system_event_manager->queueRepositoryUpdate($repository); $this->history_dao->groupAddHistory("git_repo_mirroring_update", $repository->getName(), $repository->getProjectId()); } return true; }
private function getCloneUrl() { $mirrors = $this->mirror_data_mapper->fetchAllRepositoryMirrors($this->repository); $presenter = new RepositoryClonePresenter($this->repository, $this->getAccessURLs(), $mirrors, $this->controller->isAPermittedAction('repo_management'), $this->getMasterLocationName()); $renderer = TemplateRendererFactory::build()->getRenderer(GIT_TEMPLATE_DIR); return $renderer->renderToString($presenter->getTemplateName(), $presenter); }
private function getMirrorUserNames(GitRepository $repository) { $names = array(); foreach ($this->data_mapper->fetchAllRepositoryMirrors($repository) as $mirror) { $names[] = $mirror->owner->getUserName(); } return $names; }
private function updateRepositoryMirrors(GitRepository $repository, $mirror_ids) { if ($this->mirror_data_mapper->doesAllSelectedMirrorIdsExist($mirror_ids) && $this->mirror_data_mapper->unmirrorRepository($repository->getId()) && $this->mirror_data_mapper->mirrorRepositoryTo($repository->getId(), $mirror_ids)) { $this->git_system_event_manager->queueRepositoryUpdate($repository); $this->history_dao->groupAddHistory("git_repo_mirroring_update", $repository->getName(), $repository->getProjectId()); return true; } return false; }
public function dumpAllMirroredRepositories() { foreach ($this->mirror_data_mapper->fetchAllProjectsConcernedByMirroring() as $project) { if (!$this->dumpProjectRepoConf($project)) { return false; } } return $this->updateMainConfIncludes(); }
private function getAdminMassUpdateMirrorPresenters() { $mirrors = $this->mirror_data_mapper->fetchAllForProject($this->project); $mirror_presenters = array(); foreach ($mirrors as $mirror) { $mirror_presenters[] = new GitPresenters_MirrorPresenter($mirror, false); } return $mirror_presenters; }
public function updateDefaultMirroring(Project $project, array $selected_mirror_ids) { $mirror_ids = $this->getSelectedMirrorIdsFromRequest($selected_mirror_ids, $project->getID()); if ($this->mirror_data_mapper->doesAllSelectedMirrorIdsExist($mirror_ids) && $this->mirror_data_mapper->removeAllDefaultMirrorsToProject($project) && $this->mirror_data_mapper->addDefaultMirrorsToProject($project, $mirror_ids)) { $GLOBALS['Response']->addFeedback(Feedback::INFO, $GLOBALS['Language']->getText('plugin_git', 'default_mirros_update_success')); return true; } $GLOBALS['Response']->addFeedback(Feedback::ERROR, $GLOBALS['Language']->getText('plugin_git', 'default_mirros_update_error')); return false; }
private function getMirrorPresentersForGitAdmin() { $mirrors = $this->mirror_data_mapper->fetchAllForProject($this->project); $default_mirror_ids = $this->mirror_data_mapper->getDefaultMirrorIdsForProject($this->project); $mirror_presenters = array(); foreach ($mirrors as $mirror) { $is_used = in_array($mirror->id, $default_mirror_ids); $mirror_presenters[] = new GitPresenters_MirrorPresenter($mirror, $is_used); } return $mirror_presenters; }
/** * @return array */ private function buildPanes(GitRepository $repository) { $panes = array(new GitViews_RepoManagement_Pane_GeneralSettings($repository, $this->request)); if ($repository->getBackendType() == GitDao::BACKEND_GITOLITE) { $panes[] = new GitViews_RepoManagement_Pane_Gerrit($repository, $this->request, $this->driver_factory, $this->gerrit_servers, $this->gerrit_config_templates); } $panes[] = new GitViews_RepoManagement_Pane_AccessControl($repository, $this->request); $mirrors = $this->mirror_data_mapper->fetchAllForProject($repository->getProject()); if (count($mirrors) > 0) { $repository_mirrors = $this->mirror_data_mapper->fetchAllRepositoryMirrors($repository); $panes[] = new GitViews_RepoManagement_Pane_Mirroring($repository, $this->request, $mirrors, $repository_mirrors); } $panes[] = new GitViews_RepoManagement_Pane_Notification($repository, $this->request); $panes[] = new GitViews_RepoManagement_Pane_Delete($repository, $this->request); $indexed_panes = array(); foreach ($panes as $pane) { if ($pane->canBeDisplayed()) { $indexed_panes[$pane->getIdentifier()] = $pane; } } return $indexed_panes; }
private function getWaitingForRepositoryCreationInfo() { $html = '<div class="alert alert-info wait_creation">'; $html .= $GLOBALS['Language']->getText('plugin_git', 'waiting_for_repo_creation'); $default_mirrors = $this->mirror_data_mapper->fetchAllRepositoryMirrors($this->repository); if ($default_mirrors) { $default_mirrors_names = array_map(array($this, 'extractMirrorName'), $default_mirrors); $html .= '<br/>'; $html .= $GLOBALS['Language']->getText('plugin_git', 'waiting_for_repo_creation_default_mirrors', implode(', ', $default_mirrors_names)); } $html .= '</div>'; return $html; }
private function moveProjectFiles($old_name, $new_name, Git_Gitolite_GitModifications $git_modifications, Project $project) { $old_file = 'conf/projects/' . $old_name . '.conf'; $new_file = 'conf/projects/' . $new_name . '.conf'; $this->proceedToFileMove($old_file, $new_file, $git_modifications); if (!$this->gitoliterc_reader->getHostname()) { return; } $mirrors = $this->mirror_data_mapper->fetchAllForProject($project); foreach ($mirrors as $mirror) { $this->moveProjectFileForMirror($old_name, $new_name, $git_modifications, $mirror); } }
private function deleteMirror(Codendi_Request $request) { try { $this->csrf->check(); $id = $request->get('mirror_id'); $delete = $this->git_mirror_mapper->delete($id); if (!$delete) { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_git', 'admin_mirror_cannot_delete')); } } catch (Git_Mirror_MirrorNotFoundException $e) { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_git', 'admin_mirror_cannot_delete')); } $GLOBALS['Response']->redirect('/plugins/git/admin/?pane=mirrors_admin'); }
private function mirrorForkedRepository(GitRepository $forked_repository, GitRepository $base_repository) { $base_repository_mirrors = $this->mirror_data_mapper->fetchAllRepositoryMirrors($base_repository); $project_destination = $forked_repository->getProject(); $allowed_mirrors_forked_repository = $this->mirror_data_mapper->fetchAllForProject($project_destination); $repository_mirrors_ids = array(); foreach ($base_repository_mirrors as $mirror) { if (in_array($mirror, $allowed_mirrors_forked_repository)) { $repository_mirrors_ids[] = $mirror->id; } } if ($repository_mirrors_ids) { $this->mirror_updater->updateRepositoryMirrors($forked_repository, $repository_mirrors_ids); $this->git_system_event_manager->queueRepositoryUpdate($forked_repository); } }
private function areMirrorsEnabledForProject() { return count($this->mirror_data_mapper->fetchAllForProject($this->project)) > 0; }
private function isAdminMassChangeAllowed() { return count($this->mirror_data_mapper->fetchAllForProject($this->project)) > 0; }