/** * This function initialize a GitRepository object with its database value * @param GitRepository $repository * @return <type> */ public function getProjectRepository($repository) { $projectId = $repository->getProjectId(); $repositoryPath = $repository->getPathWithoutLazyLoading(); if (empty($projectId) || empty($repositoryPath)) { throw new GitDaoException($GLOBALS['Language']->getText('plugin_git', 'dao_search_params')); } $rs = $this->searchProjectRepositoryByPath($projectId, $repositoryPath); if (empty($rs)) { throw new GitDaoException($GLOBALS['Language']->getText('plugin_git', 'dao_search_error')); return false; } $result = $rs->getRow(); if (empty($result)) { throw new GitDaoException($GLOBALS['Language']->getText('plugin_git', 'dao_search_error')); return false; } $this->hydrateRepositoryObject($repository, $result); return true; }
/** * Return true if proposed name already exists as a repository path * * @param Project $project * @param String $name * * @return Boolean */ public function isRepositoryNameAlreadyUsed(GitRepository $new_repository) { $repositories = $this->repository_factory->getAllRepositories($new_repository->getProject()); foreach ($repositories as $existing_repo) { $new_repo_path = $new_repository->getPathWithoutLazyLoading(); $existing_repo_path = $existing_repo->getPathWithoutLazyLoading(); if ($new_repo_path == $existing_repo_path) { return true; } if ($this->nameIsSubPathOfExistingRepository($existing_repo_path, $new_repo_path)) { return true; } if ($this->nameAlreadyExistsAsPath($existing_repo_path, $new_repo_path)) { return true; } } }