public function testAddMergeCommit()
 {
     $this->repositoryFiller->addCommit(100, 'user', 123, 'msg');
     $this->repositoryFiller->addCommit(200, 'user', 123, 'msg');
     $this->repositoryFiller->addCommit(300, 'user', 123, 'msg');
     $this->repositoryFiller->addMergeCommit(300, array(100, 200));
     $this->assertTableContent('Merges', array(array('MergeRevision' => '300', 'MergedRevision' => '100'), array('MergeRevision' => '300', 'MergedRevision' => '200')));
 }
Пример #2
0
 /**
  * Builds the commits. Will remove added commits after finished.
  *
  * @return void
  */
 public function build()
 {
     $commit_projects = array();
     $commit_refs = array();
     foreach ($this->_commits as $commit) {
         $commit_data = $commit->getCommitData();
         $revision = $commit_data['revision'];
         $commit_projects[$revision] = array();
         $commit_refs[$revision] = array();
         $this->_repositoryFiller->addCommit($revision, $commit_data['author'], $commit_data['date'], $commit_data['message']);
         $this->_repositoryFiller->addBugsToCommit($commit->getBugs(), $revision);
         $this->_repositoryFiller->addMergeCommit($revision, $commit->getMergedCommits());
         foreach ($commit->getPaths() as $path => $path_data) {
             $ref_name = $path_data['ref_name'];
             $project_path = $path_data['project_path'];
             // Create missing path.
             $this->createMissingPath($path, $ref_name, $project_path, $revision, $path_data['action']);
             $copy_from_path = $path_data['copy_from_path'];
             $copy_from_revision = $path_data['copy_from_revision'];
             if ($copy_from_path) {
                 $copy_from_path_id = $this->createMissingPath($copy_from_path, '', '', $copy_from_revision, 'A');
             }
             // Add path to commit.
             $this->_repositoryFiller->addPathToCommit($revision, $path_data['action'], substr($path, -1, 1) === '/' ? 'dir' : 'file', $this->_pathsMap[$path], $copy_from_revision, isset($copy_from_path_id) ? $copy_from_path_id : null);
             if ($project_path) {
                 // Create missing project & add commit to it.
                 if (!isset($this->_projectsMap[$project_path])) {
                     $this->_projectsMap[$project_path] = $this->_repositoryFiller->addProject($project_path);
                 }
                 if (!in_array($project_path, $commit_projects[$revision])) {
                     $this->_repositoryFiller->addCommitToProject($revision, $this->_projectsMap[$project_path]);
                     $commit_projects[$revision][] = $project_path;
                 }
                 if ($ref_name) {
                     $project_id = $this->_projectsMap[$project_path];
                     $ref_key = $project_id . ':' . $ref_name;
                     // Create missing project ref and add commit to it.
                     if (!isset($this->_refsMap[$ref_key])) {
                         $this->_refsMap[$ref_key] = $this->_repositoryFiller->addRefToProject($ref_name, $project_id);
                     }
                     if (!in_array($ref_key, $commit_refs[$revision])) {
                         $this->_repositoryFiller->addCommitToRef($revision, $this->_refsMap[$ref_key]);
                         $commit_refs[$revision][] = $ref_key;
                     }
                 }
             }
         }
     }
     $this->_commits = array();
 }