コード例 #1
0
    /**
     * Processes project.
     *
     * @param string  $project_path Project path.
     * @param boolean $is_usage     This is usage.
     *
     * @return integer
     */
    protected function processProject($project_path, $is_usage = true)
    {
        $sql = 'SELECT Id
				FROM Projects
				WHERE Path = :path';
        $project_data = $this->_databaseCache->getFromCache('Projects', $project_path, $sql, array('path' => $project_path));
        if ($project_data !== false) {
            $project_id = $project_data['Id'];
            // Don't consider project both new & existing (e.g. when single commit adds several branches).
            if ($is_usage && !isset($this->_projects[self::TYPE_NEW][$project_id])) {
                $this->_projects[self::TYPE_EXISTING][$project_id] = $project_path;
                $this->recordStatistic(self::STATISTIC_PROJECT_FOUND);
            }
            return $project_id;
        }
        // Ignore fact, that project of non-used (copied) path doesn't exist.
        if (!$is_usage) {
            return null;
        }
        $project_id = $this->repositoryFiller->addProject($project_path);
        $this->_databaseCache->setIntoCache('Projects', $project_path, array('Id' => $project_id));
        $this->_pathCollisionDetector->addPaths(array($project_path));
        if ($is_usage) {
            $this->_projects[self::TYPE_NEW][$project_id] = $project_path;
            $this->recordStatistic(self::STATISTIC_PROJECT_ADDED);
        }
        return $project_id;
    }
コード例 #2
0
 public function testNoCollisionWithRootPathIsKnownPath()
 {
     $this->pathCollisionDetector->addPaths(array('/'));
     $this->assertFalse($this->pathCollisionDetector->isCollision('/'));
 }