Пример #1
0
 public function updateMirroring(Project $project, array $repositories, $selected_mirror_ids)
 {
     $current_mirror_ids_per_repository = $this->mirror_data_mapper->getListOfMirrorIdsPerRepositoryForProject($project);
     foreach ($repositories as $repository) {
         if (!isset($selected_mirror_ids[$repository->getId()]) || !is_array($selected_mirror_ids[$repository->getId()])) {
             continue;
         }
         $mirror_ids = $this->getSelectedMirrorIdsFromRequest($selected_mirror_ids, $repository->getId());
         if (!$this->areThereAnyChanges($repository, $mirror_ids, $current_mirror_ids_per_repository)) {
             continue;
         }
         if (!$this->mirror_updater->updateRepositoryMirrors($repository, $mirror_ids)) {
             $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_git', 'mirroring_mirroring_error'));
             return;
         }
         $this->git_system_event_manager->queueRepositoryUpdate($repository);
     }
     $more_than_one_repository = count($repositories) > 1;
     if ($more_than_one_repository && !$selected_mirror_ids) {
         $GLOBALS['Response']->addFeedback('warning', $GLOBALS['Language']->getText('plugin_git', 'mirroring_unmirroring_successful_plural'));
     } elseif ($more_than_one_repository && $selected_mirror_ids) {
         $GLOBALS['Response']->addFeedback('warning', $GLOBALS['Language']->getText('plugin_git', 'mirroring_mirroring_successful_plural'));
     } elseif (!$more_than_one_repository && !$selected_mirror_ids) {
         $GLOBALS['Response']->addFeedback('warning', $GLOBALS['Language']->getText('plugin_git', 'mirroring_unmirroring_successful'));
     } else {
         $GLOBALS['Response']->addFeedback('warning', $GLOBALS['Language']->getText('plugin_git', 'mirroring_mirroring_successful'));
     }
 }
Пример #2
0
 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);
     }
 }